03-17-2017, 03:27 PM
Quote:4.VBA:(To manipulate specific words in the entire Microsoft Word document)Macro Find and Replace 4
Const wdReplaceAll = 2
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
Set objDoc = objWord.Documents.Open("C:\Scripts\Test.doc")
Set objSelection = objWord.Selection
objSelection.Find.Text = "Fabrikam"
objSelection.Find.Forward = TRUE
objSelection.Find.MatchWholeWord = TRUE
objSelection.Find.Replacement.Font.Bold = True
objSelection.Find.Execute ,,,,,,,,,,wdReplaceAll
;/exe 1
typelib Word {00020905-0000-0000-C000-000000000046} 8.0
Word.Application app._create
Word.Documents doc=app.Documents
str WordDoc="$desktop$\Scripts\Test.docx"
VARIANT vWordFile=WordDoc.expandpath
doc.Open(vWordFile)
app.Selection.Find.Text = "Fabrikam"
app.Selection.Find.Forward=1
app.Selection.Find.MatchWholeWord=1
app.Selection.Find.Replacement.Font.Bold=1
VARIANT vReplace=Word.wdReplaceAll
app.Selection.Find.Execute(@ @ @ @ @ @ @ @ @ @ vReplace)
app.ActiveDocument.Save
app.ActiveDocument.Close
app.Quit