Insert bookmark at end of document

F

FertRob

I,m trying to insert a bookmark at the end of a document. I tried
several things but nothing works. I'm working with word 2000 this is the
code i'm using

Dim pRange As Word.Range, Hdoc As Document


If Hdoc.Bookmarks.Exists("OndTek") = False Then
Set pRange = ??????????????
Else
Set pRange = Hdoc.Bookmarks("OndTek").Range
End If

pRange = StrOndertekening
Hdoc.Bookmarks.Add Name:="OndTek", Range:=pRange

On the ??????? i tried hdoc.goto, selection, hdoc.end etc nothing works,
i am getting errors on object en type not corresponding.

Can anyone help me

Thanks
Robert
 
D

Dave Lett

Hi Robert,

You can you the following to insert a bookmark at the end of a document:

Dim oRng As Range
Set oRng = ActiveDocument.Range
oRng.Collapse Direction:=wdCollapseEnd
ActiveDocument.Bookmarks.Add Name:="EndOfDoc", Range:=oRng

HTH,
Dave
 
H

Helmut Weber

Hi,

I don't understand your code, but anyway,
there is a predefined bookmark "endofdoc",
like this:
ActiveDocument.Bookmarks("\EndofDoc").Select

Greetings from Bavaria, Germany

Helmut Weber, MVP
"red.sys" & chr(64) & "t-online.de"
Word XP, Win 98
http://word.mvps.org/
 
F

FertRob

Thanks Helmud,

i totaly forgot about these predefined bookmarks. I will use you option.

Robert
 

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