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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Page Deletion 1

Status
Not open for further replies.

tyang01

Technical User
Feb 1, 2007
46
0
0
US
Hi I am working on deleting a 3rd page from a 10 page document in word 2003. I'm not sure where to start I am trying to automate this using VBA and the page is not manual page break. If you have any pointers I would appreciate it.

Thanks.
 
Do you know the contents of the page to be deleted or do you know the end of the second and start of fourth pages ?


Chance,

F, G and Skipper
 




What is distinct about page 3, that you need it deleted?

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Hi Chance1234,

The contents at the end of second page and the beginning of the fourth page are bookmarks. The bookmark name at the end of page 2 is TPRTA5 and the bookmark name at the begining of page 4 is ISTA51.
 
Hey Skip,

Yeah there are just normal text on page 3. There is nothing distinct about page 3. Just that people would rather just have a macro of some sort to delete content on the page rather then spending the time and selecting the text and deleting it themselves.
 
If this is the case....

"The bookmark name at the end of page 2 is TPRTA5 and the bookmark name at the begining of page 4 is ISTA51. "

Then this is fairly easy. Make a Range object with its Start = the End of TPRTA5, and its End = the Start of ISTA51 - 1, and delete it. Like so:
Code:
Dim r As Range
Set r = ActiveDocument.Range( _
   Start:= _
   ActiveDocument.Bookmarks("TPRTA5").Range.End, _
   End:= _
   ActiveDocument.Bookmarks("ISTA51").Range.Start - 1)
r.Delete

Note: this does NOT delete page 3. It deletes the range, whatever its length, between the bookmarks TPRTA5 and ISTA51.

Hope this helps.

faq219-2884

Gerry
My paintings and sculpture
 
Thank you Fumei! This will work great for me. And thank you Skip and Chance.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top