VBA Code to go to one Bookmark.

J

Juan

I have a Tabe of Contents bookmarked on Page 2 titled Table_Of_Contents in a
Word Document.

Can someone help me on the VBA code. I have the following written but it
says that the bookmark does not exist.

Private Sub CommandButton1_Click()
Selection.GoTo What:=wdGoToBookmark, Which:=wdGoToFirst
End Sub

As a second question, is it possible to have this command button follow each
page on its own as someone scrolls through the document. It's a 115 page
document and i thought it would be easy for the button to float along each
page on the side. Or possibly have it at the top of each section. There are
a total of 6 sections.

Thanks.
 
D

Doug Robbins - Word MVP

Use

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

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
J

Juan

Perfect!! That worked. Thanks so much.

Can you also tell me how to add it to a macro list or have it appear on the
word document ready for use?
 
D

Doug Robbins - Word MVP

I am not sure what you mean by add it to a macro list, but you can add it to
a toolbar by right clicking on the toolbar and selecting Customize and then
on the Commands tab, scroll down to the Macros category and then locate the
macro and click and drag it onto a toolbar.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

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