Hi All, im pretty new to all of this and hoping someone can help me...
I have a workbook with 7 sheets which i have renamed at the bottom of the workbook, each sheet will have a separate macro that will populate a single word.dox, on the last sheet i have created a button which i would like to run all macros to generate the single word.dox template
I currently have 3 issues:
Macro1: Works completely fine when i run the macro from the first tab: Code below
Sub ReplaceText()
Set ws = ThisWorkbook.Sheets("Pre Req")
Dim WordApp As Object
Dim wdoc As Object
Set wAPP = CreateObject("Word.Application")
wAPP.DisplayAlerts = False
wAPP.Visible = True
Set wdoc = wAPP.Documents.Add(Template:="C:\Users\ANash\Desktop\Site Survey VBA TEST 001.docx", NewTemplate:=False, DocumentType:=0)
With wdoc
.Application.Selection.Find.Text = "<<Customer>>"
.Application.Selection.Find.Execute
.Application.Selection = Range("C2")
.Application.Selection.EndOf
.Application.Selection.Find.Text = "<<Customer Site>>"
.Application.Selection.Find.Execute
.Application.Selection = Range("C3")
.Application.Selection.EndOf
End With
End Sub
Macro 2 - I need this macro to run directly after the 1st macro and extract information from the second sheet into a section in the word document; problem i have is that when i run macro 2 nothing happens in the word document .
Macro 2:
Sub ReplaceText()
With wdoc
.Application.Selection.Find.Text = "<<RO12>>"
.Application.Selection.Find.Execute
.Application.Selection = Range("B12")
.Application.Selection.EndOf
End With
End Sub
Third issue i have is when i use the button to run the macros the word template opens.. but absolutely no information is extracted from Excel into the word.dox template ( but when i run the 1st macro in its sheet it will open the word.dox and pull the required information into the document.
Macro 3:
Sub Button1_Click()
Call Module1.ReplaceText 'Macro1
Call Module2.ReplaceText 'Macro2
End Sub
Any help or guidance will be greatly appreciated
Bookmarks