Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
EPPack EPPack is offline
external usenet poster
 
Posts: 2
Default Create hyperlink via macro? Word 2007

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
Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
how to create a "link" in word 2007 without using "hyperlink"? Rakhi New Users 1 April 7th 10 05:47 AM
Create hyperlink via macro? Word 2007 EPPack Microsoft Word Help 4 March 17th 10 08:08 PM
How to create an email from mail merge including a hyperlink, so that the value of a merged field is included as part of the hyperlink URL, not just part of its text. [email protected] Mailmerge 4 August 22nd 07 06:18 PM
How to create an email from mail merge including a hyperlink, so that the value of a merged field is included as part of the hyperlink URL, not just part of its text. [email protected] Mailmerge 0 August 17th 07 03:52 PM
Word: I create a hyperlink to a pdf. I ctrl-click on hyperlink, . Bruce Microsoft Word Help 0 February 18th 05 03:57 AM


All times are GMT +1. The time now is 08:16 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"