Find and Replace blocks of code not running...

C

codwilco

I have multiple block of Find and Replace code that are being called. They
seem to run haphazardly though. In other words, they don't all work. I
thought it was because a previous block found something and then the next
block started from where the previous left off. The Set objRange =
objDoc.Range should make it search the entire doc though...I thought??

Thanks,
Dave

Code Sample...
Const wdReplaceAll = 2

Set objWord = CreateObject("Word.Application")
objWord.Visible = True
Set objDoc = objWord.Documents.Open("r:\is\troy\595566Test.rtf")
Set objRange = objDoc.Range
Set objFind = objRange.Find

objFind.ClearFormatting
objFind.Replacement.ClearFormatting
objFind.Text = "performance"
objFind.Forward = True
objFind.Replacement.Text = "preformance"
objFind.Execute ,,,,,,,,,,wdReplaceAll

objFind.ClearFormatting
objFind.Replacement.ClearFormatting
objFind.Font.Size = 4
'objFind.Forward = True
objFind.Replacement.Font.Size = 9
objFind.Execute ,,,,,,,,,,wdReplaceAll

Set oSec = objDoc.Sections(2)
oSec.Footers(1).LinkToPrevious = False
oSec.Footers(1).Range.Text = ""
oSec.Footers(1).Range.Font.Name = "Arial"
oSec.Footers(1).Range.Font.Size = 10
oSec.Footers(1).Range.Bold = False
'oSec.Footers(1).Range.Delete
'Problem making it change the color dark blue every time.
oSec.Footers(1).Range.Font.ColorIndex = wdDarkBlue
oSec.Footers(1).Range.Text = "Accepted by
__________________________________ Date ____________"
oSec.Footers(1).Range.WholeStory
oSec.Footers(1).Range.ParagraphFormat.Alignment = 1
oSec.Footers(1).PageNumbers.Add(wdAlignPageNumberCenter)

Set objFind = Nothing
Set objRange = Nothing
Set objDoc = Nothing
Set objWord = Nothing

WScript.Quit(0)
 

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