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 / February 2006

Tip: Looking for answers? Try searching our database.

Hyperlink to the next(or previous) bookmark

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Dan Perkins - 07 Feb 2006 14:08 GMT
I know how to add a hyperlink to a bookmark, and I know that I can use
Selection.Goto to move to the next or previous bookmark in my document, what
I want to do is somehow combine these so that when the user clicks on the
hyperlink it will goto the next or previous bookmark.
How can I do this?
Dave Lett - 07 Feb 2006 15:03 GMT
Hi Dan,

You can use something like the following:

Dim lBkMk As Long

lBkMk = ActiveDocument.Range(0,
Selection.Paragraphs(1).Range.End).Bookmarks.Count
With Selection.Hyperlinks
   .Add _
   Anchor:=Selection.Range, _
   SubAddress:=ActiveDocument.Range.Bookmarks(lBkMk), _
   ScreenTip:="GoTo Previous Bookmark", _
   TextToDisplay:="Previous bookmark"
   Selection.TypeParagraph
   .Add _
   Anchor:=Selection.Range, _
   SubAddress:=ActiveDocument.Range.Bookmarks(lBkMk + 1), _
   ScreenTip:="GoTo Next Bookmark", _
   TextToDisplay:="Next bookmark"
End With

HTH,
Dave

> I know how to add a hyperlink to a bookmark, and I know that I can use
> Selection.Goto to move to the next or previous bookmark in my document, what
> I want to do is somehow combine these so that when the user clicks on the
> hyperlink it will goto the next or previous bookmark.
> How can I do this?
Dan Perkins - 07 Feb 2006 15:49 GMT
Ok, I got that to work, sort of.

Let me better explain what I am trying to do and that might help

I have a document with program source code. This code contains changes to
the original made by me and by others. In order for another programmer to
verify my changes, they need to know what changes are mine. So, we have a
document that lists all of the source code for our task, we then go and
highlight our changes to the source code.
What I am trying to do is to make that task a little simpler by providing
links to the changes in the source code. This means that as I find each
change, I am adding in a bookmark, highlighting the change and adding a
hyperlink from the top of the document to that bookmark. Then I want to add a
hyperlink from the current bookmark to the next bookmark, the previous
bookmark, and the top of the document.

The solution you suggested works great when I add the first hyperlink to
next and previous, but adding in a second one does not change the bookmark
that the first hyperlink points to. I am guessing that I need to somehow
refresh the hyperlink settings or something like that.

Thanks again for the help

> Hi Dan,
>
[quoted text clipped - 26 lines]
> > hyperlink it will goto the next or previous bookmark.
> > How can I do this?
Dave Lett - 07 Feb 2006 18:49 GMT
Hi Dan,

Inserting hyperlinks like this is not dynamic, so we should expect the
previous hyperlinks to insert in the same manner. You can certainly create a
system that inserts a group of hyperlinks based on some condition that you
control.

Are you sure that you're using the correct tool? After all, you could be
using the Track Changes feature and skip the VBA completely. The Track
Changes feature will allow your user to browse each change, and Word
controls/updates when a change is accepted or rejected.

It won't create a table of contents for your changes. However, you can
insert your changes with a custom style and create a table of contents based
on that style. For example:
{ TOC \t "InsertedChanges,1" }

HTH,
Dave

> Ok, I got that to work, sort of.
>
[quoted text clipped - 49 lines]
> > > hyperlink it will goto the next or previous bookmark.
> > > How can I do this?
Dan Perkins - 08 Feb 2006 14:39 GMT
Dave,
Thanks, I get so caught up in thinking of programming solutions that I
sometimes overlook the obvious. I think that using track revisions would
certainly make this easier.
I will still need to do this via a macro app, but from what I see, I should
be able to mark text add inserted, changed, or deleted. A quick test makes it
look like the revisions are dynamic so using the NextRevision and
PreviousRevision Methods would all me to easily jump between them.

> Hi Dan,
>
[quoted text clipped - 69 lines]
> > > > hyperlink it will goto the next or previous bookmark.
> > > > How can I do this?
 
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.