Excel VBA Macro: Create Word Document (and Write with Excel)

preview_player
Показать описание
Excel VBA Macro: Create Word Document (and Write with Excel). In this video, we go over how to use excel vba to open a new word doc and type text into the document. We go over how to type directly from a string in our code, and by using a string from a cell in an excel workbook.

Code:

Sub create_word_doc()

Dim objWord
Dim objDoc

Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Add

With objWord

.Visible = True
.Activate

End With

End Sub

#ExcelVBA #ExcelMacro
Рекомендации по теме
Комментарии
Автор

Holy mother of God! This one works!!! All else failed!!! Thank you, Greg!

francesoutlaw
Автор

Can you make a video on how to create a template word document and type the text present in a given excel cell to a specific place (specific paragraph, range of characters or specific textbox) in the word document: For instance, there is a excel sheet with with several fields (name, age, town..). The point is to creat a macro so that after you fill those fields in Excel, a word document is created with those same fields filled

filipeempis
Автор

why mine got "user defined - not define" pls helppp

darkzlord
Автор

Mr. Greg, may I request you write a script to open an existing Word document, pweeeez! The Word document I need to open has an AutoExec macro to finalize the mail merge. The AutoExec macro works well that when I open the file, it is already merged with the data. Now, I just need to open that Word file from the Userform. Thanks in advance!

francesoutlaw