Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA for Word 1

Status
Not open for further replies.

mike718

Programmer
Jul 7, 2004
58
US
How do you read in Page Breaks using VBA for Word. I have to select the contents between each page break. Can anyone give me a hand?? Thanks
 
To find a page break (^m), try this:

With Selection.Find
.Text = "^m"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
 
ActiveDocument.Bookmarks("\page").Select

will select everything between the start of the current page, and the end of the current page. This is regardless of whether it is a forced page break (you inserted a page break), or a flow page break (the text flowed into the next page.

It selects the current page.

Now, if you are wanting to loop through EACH page of a document, one by one - and doing something with each one - that is a different matter. Could you clarify exactly what you want to do?


Gerry
 
Thanks for the help Gerry. That worked beautifully
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top