VB cant find bookmark in Header

S

Sukhi

Hello again
I have bookmark in Header, When I try to get to it in VB with the code --

objWord.ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.GoTo What:=wdGoToBookmark, Name:="HeaderPlanName"

I get the error 5678
"Word cannot find the reuested bookmark."

even though the above is generated by word it self (by recording macro).
Help please!!!
You guys have been great so far
 
J

Jonathan West

Sukhi said:
Hello again
I have bookmark in Header, When I try to get to it in VB with the code --

objWord.ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.GoTo What:=wdGoToBookmark, Name:="HeaderPlanName"

I get the error 5678
"Word cannot find the reuested bookmark."

even though the above is generated by word it self (by recording macro).
Help please!!!
You guys have been great so far

Instead of this

Selection.GoTo What:=wdGoToBookmark, Name:="HeaderPlanName"

use this

ActiveDocument.Bookmarks("HeaderPlanName").Range.Select

The Selection.Goto method only works where the bookmark is in the same
storyrange as the selection.

--
Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org
 
H

Helmut Weber

Hi,

yes, as Jonathan said,

and in addition, there is hardly a situation,
in which you need to select the bookmark at all.

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 

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