Word dialog editreplace

G

Guest

The following code opens a word document to be edited. The WordDialog is to
find and replace the text without user interaction. How do I get the Word
Dialog to do this???? WordDialog.execute doesn't work. Any ideas?????


Set WordApp = CreateObject("word.application") 'open Word session
WordApp.Visible = True 'Word visible during operation
WordApp.Activate
Set WordDoc = WordApp.Documents.Open(file_path) 'open Word doc
Set WordDialog = WordApp.Dialogs(wdDialogEditReplace)
With WordDialog
.Find = "<RIA name>"
.Replace = "TESTING!!!"
End With
On Error Resume Next
WordDialog.Execute
On Error GoTo Err_WordDocs

Thank You,
 
H

Harald Staff

Hi

Dialogs ARE for user interaction. Without user interaction don't use
dialogs.

Record a macro in Word as you do a manual find-replace, and you'll get
pretty good code for automatic find-replace.

HTH. Best wishes Harald
 
G

Guest

Figured it out, Thanks for the Help!

Set WordApp = CreateObject("word.application") 'open Word session
WordApp.Visible = True 'Word visible during operation
WordApp.Activate
Set WordDoc = WordApp.Documents.Open(file_path) 'open Word doc

With WordDoc.Content.Find
.text = "<RIA name>"
With .Replacement
.text = "testing!!!"
End With
.Execute Replace:=wdReplaceAll
End With

On Error Resume Next
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top