PDA

View Full Version : Solved: Hyperlinking to bookmarks in a word document



charliew001
06-14-2012, 11:29 AM
Looking for some technical assistance. Would like to be able to create a dropdown list that will bring up hyperlinks to a MS word document bookmark. The list would show 10 values, like A, B, C, D, E, F and so on. Once I select A for instance, it would open the worddocument with bookmark A.

Thank You

Tinbendr
06-14-2012, 01:07 PM
Here's an example.

This assumes that the combobox values and the Bookmark Names are the same.

You could always load the bookmark names INTO the combobox. (Look at userform2)

HTH

charliew001
06-14-2012, 03:24 PM
Thank you David for this great code. I've been able to have it load my own word document and load the bookmarks that my own document already has. One problem is when I use userform 2, it opens the document but does not go to the proper book mark. Please let me know if I need to edit anything else in the code. I've only changed the code to refer to my document only for user for 2.

Tinbendr
06-14-2012, 03:41 PM
Just copy the code from the Commandbutton1_click in userform1 to the same event in userform 2.

I call myself checking UF2, but I might have missed something.

I did notice, too, that it would work perfect while the code was in Word, but when I moved it to Excel, it wouldn't always give me the same results. You may have to play around with the scroll.

charliew001
06-14-2012, 04:15 PM
for some reason it seemed like the code was working as intended when I first begun using the code, but now it keeps going to the same place in the word document. Nonetheless, this is one of the more elegant solutions i have come across to help me solve my problem. Thank you.

I decided to not tinker with anything except the file path directory and it seems like the code only scrolls down 1 page rather than goes to the bookmark. Please let me know if there could be some fix to this.

Thank You

Tinbendr
06-15-2012, 04:51 AM
This seems to be working on my machine.

Replace this code in the Commandbutton1_click event.

If oWordDoc.bookmarks.exists(Me.ComboBox1) Then
oWordDoc.GoTo what:=wdGotoBookMark, Name:=Me.ComboBox1.Value
oWordDoc.bookmarks(Me.ComboBox1).Select
oWordDoc.ActiveWindow.SmallScroll down:=30
oWord.Visible = True
End If

Tinbendr
06-15-2012, 01:21 PM
Make sure you aren't running multiple copies of Word. If the code stops (or you stop it) and it doesn't get to the end of the code where are the =Nothing's are, there will be a instance of Word running and it won't show in the taskbar. You have to goto the task manager and sort the Processes by name and look for multiple instances of WINWORD.EXE.

charliew001
06-15-2012, 02:50 PM
Noted. Thanks!

Code works like a charm now.