E
EPPack
Having a problem creating a macro to insert a hyperlink in Word 2007. Here's
exactly what I want it to do:
1. AFTER I highlight a few words or so in the document, I press the
button/hotkeys that kicks off the macro
2. The Insert Hyperlink box comes up
3. The address bar gets prefilled with EXACTLY the same text (a lengthy,
unchanging path to a file) EVERY TIME, then the macro STOPS or PAUSES running
so that the user can enter a specific file name, which will change each time,
thus completing the full path.
4. I click on OK and the hyperlink is created correctly.
5. We only see the clickable text in the document, as a link to the fully
qualified file name as entered, NOT the actual hyperlink code.
The problem:
When I recorded the macro initially, I typed in the path string uneventfully
but there's no way to stop or pause the recording at this point, because it's
in a dialog box. If I let it finish, because it never paused to let me enter
a file name, there's not one in the resulting hyperlink. In addition, because
it also captured the highlighted text, even tho it was highlighted before
starting to record, running this macro a second time replaces the new
highlighted text with the highlighted text from the previous hyperlink.
I believe that with judicious editing of the macro in VBA maybe this can all
be done, but I'm simply not familiar enough with the code to do that. This is
the code it generated:
Sub HyperlinkPath()
' HyperlinkPath Macro
ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:= _
"http://www.albemarle.org/upload/images/forms_center/board_of_supervisors/forms/agenda/2010files/" _
, SubAddress:="", ScreenTip:="", TextToDisplay:= _
"First Highlighted Text"
Is this even doable? If so, can someone point me to a solution?
TIA
elaine
charlottesville, va
exactly what I want it to do:
1. AFTER I highlight a few words or so in the document, I press the
button/hotkeys that kicks off the macro
2. The Insert Hyperlink box comes up
3. The address bar gets prefilled with EXACTLY the same text (a lengthy,
unchanging path to a file) EVERY TIME, then the macro STOPS or PAUSES running
so that the user can enter a specific file name, which will change each time,
thus completing the full path.
4. I click on OK and the hyperlink is created correctly.
5. We only see the clickable text in the document, as a link to the fully
qualified file name as entered, NOT the actual hyperlink code.
The problem:
When I recorded the macro initially, I typed in the path string uneventfully
but there's no way to stop or pause the recording at this point, because it's
in a dialog box. If I let it finish, because it never paused to let me enter
a file name, there's not one in the resulting hyperlink. In addition, because
it also captured the highlighted text, even tho it was highlighted before
starting to record, running this macro a second time replaces the new
highlighted text with the highlighted text from the previous hyperlink.
I believe that with judicious editing of the macro in VBA maybe this can all
be done, but I'm simply not familiar enough with the code to do that. This is
the code it generated:
Sub HyperlinkPath()
' HyperlinkPath Macro
ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:= _
"http://www.albemarle.org/upload/images/forms_center/board_of_supervisors/forms/agenda/2010files/" _
, SubAddress:="", ScreenTip:="", TextToDisplay:= _
"First Highlighted Text"
Is this even doable? If so, can someone point me to a solution?
TIA
elaine
charlottesville, va