Exit Loop

woodchuckwood

Registered User.
Local time
Today, 15:17
Joined
Jan 15, 2004
Messages
10
HELP: Stop this LOOP!

This is what i'm trying to do:

Search whole document for "@~Table" heading
Change the Page orientaion of all pages with "@~Table" heading to landscape
Change "@~Table" header to "Test"
Continue process until all @~table headers are changed


--------------------------------------------------------------


Do While 'how can i kill the loop
Selection.Find.ClearFormatting

If Selection.Find.Text = Trim("@~Table") Then



Selection.Find.Execute

With Selection.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientLandscape
.TopMargin = InchesToPoints(1)
.BottomMargin = InchesToPoints(1)
.LeftMargin = InchesToPoints(1)
.RightMargin = InchesToPoints(1)
.Gutter = InchesToPoints(0)
.HeaderDistance = InchesToPoints(0.5)
.FooterDistance = InchesToPoints(0.5)
.PageWidth = InchesToPoints(11)
.PageHeight = InchesToPoints(8.5)
.FirstPageTray = wdPrinterFormSource
.OtherPagesTray = wdPrinterFormSource
.SectionStart = wdSectionNewPage
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.VerticalAlignment = wdAlignVerticalTop
.SuppressEndnotes = False
.MirrorMargins = False
.TwoPagesOnOne = False
.GutterPos = wdGutterPosLeft
End With


'Selection.Find.Execute
With Selection.Find
.Text = "@~Table"
.Replacement.Text = "Test"
'.Forward = True
.Execute Replace:=wdReplaceOne, Forward:=True, Wrap:=wdFindContinue
End With
End If
Selection.Find.Execute Forward:=True
Loop


--------------------------------------------------
Tried "Do until EOF" but it does not like EOF.

I noticed that in the last section of code executed by itself "....... .Execute Replace:=wdReplaceOne, Forward:=True, Wrap:=wdFindContinue" is changed to "Execute Replace:=wdReplaceAll...", all instances of @~Table were changed to Test for the whole document. Is this the type of approach that i should use instead of the loop?
 

Users who are viewing this thread

Back
Top Bottom