Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / April 2005

Tip: Looking for answers? Try searching our database.

Clearing Whitespace after a bookmark

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dave - 28 Apr 2005 21:00 GMT
Hello All,
I have a bookmark at the end of template called End. I'd like to be able to
programatically get rid of any extra whitespace or unessary pages after this
bookmark using a macro.

Any suggestions? Any help would be greatly appreciated.

Thanks,

dave
Jean-Guy Marcil - 28 Apr 2005 21:18 GMT
Dave was telling us:
Dave nous racontait que :

> Hello All,
> I have a bookmark at the end of template called End. I'd like to be
> able to programatically get rid of any extra whitespace or unessary
> pages after this bookmark using a macro.
>
> Any suggestions? Any help would be greatly appreciated.

And if there is text after this bookmark?

If the text must go as well, then try this:

Dim cutRge As Range
Dim endPos As Long

With ActiveDocument
   endPos = .Bookmarks("End").Range.End + 1
   If endPos < .Range.End Then
       'the -1 is to exclude the last ¶ in the document from the range to
delete
       Set cutRge = .Range(endPos - 1, .Range.End - 1)
       cutRge.Delete
   End If
End With

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org

Dave - 28 Apr 2005 23:52 GMT
Thank you, I will give this a shot.
There should not be any text after the end bookmark since all text is
entered via userforms and preceeding bookmarks.

Thanks again!

> Dave was telling us:
> Dave nous racontait que :
[quoted text clipped - 22 lines]
>     End If
> End With
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.