J
JasonC
I have a macro in Excel which opens up a Word doc then updates data to the
doc. I want to use find and replace to update some text. Rather than
replace all, I am using the find replace dialog box, so the user can check
each found text.
The trouble is, the code keeps executing while the dialog box is open in
word, and some of the subsequent steps crash when the dialog box is still
open. I can't move this code to the end either. Is there a way to tell
Excel to wait while the dialog box in Word is still open? See below for the
stripped down version of my sub.
Sub temp_Update_Document()
Dim docpath As String
Dim wdapp, objdoc As Object
'open word doc
docpath = "C:\Test Find & Replace.doc"
Set wdapp = CreateObject("Word.Application")
wdapp.Visible = True
Set objdoc = wdapp.Documents.Add(docpath)
'set the find and replace text
With wdapp.Selection.Find
.Text = "April"
.Replacement.Text = "May"
End With
'open the find & replace window
wdapp.Application.CommandBars("Edit").Controls("Replace...").Execute
'I want Excel to be wait here, instead of continuing to execute the code
End Sub
doc. I want to use find and replace to update some text. Rather than
replace all, I am using the find replace dialog box, so the user can check
each found text.
The trouble is, the code keeps executing while the dialog box is open in
word, and some of the subsequent steps crash when the dialog box is still
open. I can't move this code to the end either. Is there a way to tell
Excel to wait while the dialog box in Word is still open? See below for the
stripped down version of my sub.
Sub temp_Update_Document()
Dim docpath As String
Dim wdapp, objdoc As Object
'open word doc
docpath = "C:\Test Find & Replace.doc"
Set wdapp = CreateObject("Word.Application")
wdapp.Visible = True
Set objdoc = wdapp.Documents.Add(docpath)
'set the find and replace text
With wdapp.Selection.Find
.Text = "April"
.Replacement.Text = "May"
End With
'open the find & replace window
wdapp.Application.CommandBars("Edit").Controls("Replace...").Execute
'I want Excel to be wait here, instead of continuing to execute the code
End Sub