Clearing Whitespace after a bookmark

D

Dave

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
 
J

Jean-Guy Marcil

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


--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
D

Dave

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!
 

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