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

  Рет қаралды 20,053

greggowaffles

greggowaffles

Жыл бұрын

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
.Selection.typetext ("Hello World!")
.Selection.typeparagraph
.Selection.typetext (ThisWorkbook.Sheets("Sheet1").Cells(1, 1).Text)
End With
End Sub
#ExcelVBA #ExcelMacro

Пікірлер: 16
@francesoutlaw7021
@francesoutlaw7021 Жыл бұрын
Holy mother of God! This one works!!! All else failed!!! Thank you, Greg!
@greggowaffles
@greggowaffles Жыл бұрын
No problem! So happy to hear that!!
@filipeempis5781
@filipeempis5781 Жыл бұрын
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
@Andrew-gr4nd
@Andrew-gr4nd 4 ай бұрын
Hey did you ever figure this out? If so any good resources?
@francesoutlaw7021
@francesoutlaw7021 Жыл бұрын
Subscribed, BTW! 😊
@alializadeh8195
@alializadeh8195 Жыл бұрын
Thanx
@greggowaffles
@greggowaffles Жыл бұрын
No prob!
@haideraljubouri
@haideraljubouri Жыл бұрын
@@greggowaffles I have a really interesting project and would love your input on it my man.
@darkzlord8436
@darkzlord8436 Жыл бұрын
why mine got "user defined - not define" pls helppp
@nixnews2267
@nixnews2267 Жыл бұрын
Please make a video of mailmerge..
@greggowaffles
@greggowaffles Жыл бұрын
I’ll do that soon. Thanks for sharing that idea!
@francesoutlaw7021
@francesoutlaw7021 Жыл бұрын
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!
@greggowaffles
@greggowaffles Жыл бұрын
I’ve got a backlog of requests I need to catch up on but I can look into this soon!
@francesoutlaw7021
@francesoutlaw7021 Жыл бұрын
@@greggowaffles, Thanks a million! I'm in the second part of my project that is due mid-July, and that script will be used later toward the deadline. I'm currently re-formatting 44 500-page Word documents, inserting merge fields, and formulating conditional fields, which take time, too. That script is best to do after all the templates are done. So, no hurry! Thanks again! 👍👍👍
@francesoutlaw7021
@francesoutlaw7021 Жыл бұрын
@@greggowaffles, Hello! Never mind my question above. I figured it out myself with the help of two VBA posts I combined together. Here's the script (for reference if anyone needs it): Public Sub CheckBox1_Click() Dim WrdPara As Paragraph Dim ActDom As Document Set ActDom = ActiveDocument Set WrdPara = ActDom.Paragraphs(2) If (CheckBox1.Value = True) Then ActiveDocument.Bookmarks("Para2").Range.Font.Hidden = CheckBox1.Value Else ActiveDocument.Bookmarks("Para2").Range.Font.Hidden = False End If End Sub It works perfectly.
@jeffiesconiers7798
@jeffiesconiers7798 Жыл бұрын
💘 𝘱𝘳𝘰𝘮𝘰𝘴𝘮
Excel VBA Macro: Create Word Document & Add Table (Static Range)
9:32
Wait for the last one! 👀
00:28
Josh Horton
Рет қаралды 133 МЛН
когда повзрослела // EVA mash
00:40
EVA mash
Рет қаралды 3,8 МЛН
Luck Decides My Future Again 🍀🍀🍀 #katebrush #shorts
00:19
Kate Brush
Рет қаралды 8 МЛН
Auto-populate a word document with excel data
4:23
LTalpacas
Рет қаралды 164 М.
(1/2) Automating Word Documents from Excel - No VBA
4:37
Andrew Ligon Fant
Рет қаралды 350 М.
Automate Word Document from Excel Using VBA
7:45
Nodes Automations
Рет қаралды 49 М.
Push Data from Excel to MS Word Content Controls using Excel VBA
7:55
Dr. Todd Grande
Рет қаралды 92 М.
Add Data to Specific Sheet from User Form - Advanced Excel VBA Userform
25:56
Import Data from Excel into Word Automatically Using VBA
18:23
Dinesh Kumar Takyar
Рет қаралды 282 М.
How To Work With Paragraphs In Word VBA
16:28
Sigma Coding
Рет қаралды 13 М.
Wait for the last one! 👀
00:28
Josh Horton
Рет қаралды 133 МЛН