Greg
Fri Oct 21 20:55:57 CDT 2005
Casey Mac,
Yes I think it is doable. Granted the code on my website is a spider web
and complex. That is mainly because I am a amateur and don't know any
better. Still it creates a list of all bookmarks in the document. All you
have to do is replicate that feature to give you a screen to pick the
bookmark name from. Just start in the module "Bookmarker" with the routine
"Open Bookmarker" and step through the sequence. You will see how the
listbox is populated with each bookmark name.
HTH
--
Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.
Casey Mac wrote:
> I did take look at the site and unfortunatly it is way over my head
> (VBA wise) as well as it doesnt do exactly what i want. The code
> below asks a user for a word to find and then a hyperlink to insert. Then
> what name to give that hyperlink. So essentially its a
> find/replace. my issue is, the hyperlink that im getting the user to
> input is really a name of a file (relative link to a file). Works
> great for external links. I then got to thinking that there as some
> places in the document i would like to link to. So if i some how
> could insert the names of all the book marks and choose the on i
> wanted i would have a link internal to the document. What would be
> equally usefull would be to bring up the book mark screen that comes
> up when you want to instert a bookmark.
> Do you think this is possible or am i just a dreamer?
>
>
> Sub FindReplaceYesNo()
> Dim rDoc As Range ' range replace
> Dim sFnd As String ' string to be found
> Dim sHpl As String ' hyperlink
> Dim sDsp As String ' hyperlink display
> Dim iCount As Integer ' Replace Count
> sFnd = InputBox("Enter the word you wish to replace with a
> hyperlink:") sHpl = InputBox("Enter File Name:")
> sDsp = InputBox("Enter the HyperLink display name")
> Set rDoc = ActiveDocument.Range
> With rDoc.Find
> iCount = 0
> .Text = sFnd
> .Wrap = wdFindStop
> Do While .Execute
> iCount = iCount + 1
> rDoc.Select
> If MsgBox("Replace Highlighted Selection?", vbYesNo, "Replace
> Text") = vbYes Then
> ActiveDocument.Hyperlinks.Add _
> rDoc, sHpl, TextToDisplay:=sDsp
> rDoc.End = rDoc.End + Len(sDsp)
> rDoc.Collapse wdCollapseEnd
> End If
> Loop
> End With
> If iCount > 0 Then
> MsgBox "Number of Highlighted Words Found = " & iCount, vbInformation,
> "Results Box"
>
> End If
> End Sub
>
>
> "Greg Maxey" <gmaxey@mvps.OscarRomeoGolf> wrote in message
> news:u%23rVxqp1FHA.3376@TK2MSFTNGP14.phx.gbl...
>> Greg has been busy posting refinements thanks to suggestions from
>> Helmut and Graham and his own stumbling about in the dark.
>>
>> I have revised the code to show messages and alerts using either the
>> Office Assistant or traditional message boxes. I also thought it
>> would be nice to add a method to throw in a quick bookmark with the
>> click of a button. The added "Quick Mark" button inserts a
>> sequentially numbered bookmark at the selection.
>>
>> One of the gentlemen named above was so forward as to suggest
>> spelling corrections. Those are made, but I am prone to error so
>> there could be more.
>>
>> The web page was just updated so visit:
>>
http://gregmaxey.mvps.org/Bookmark_Tool.htm
>> for a look see. Constructive comments always welcomed.
>>
>> --
>> Greg Maxey/Word MVP
>> See:
>>
http://gregmaxey.mvps.org/word_tips.htm
>> For some helpful tips using Word.
>>
>> Anne Troy wrote:
>>> Greg Maxey has a very cool, new bookmark tool on his site available
>>> for download. Perhaps you can use the tool directly, or yoink some
>>> of his code to suit your needs:
>>>
http://gregmaxey.mvps.org/Bookmark_Tool.htm
>>> ************
>>> Anne Troy
>>> www.OfficeArticles.com
>>>
>>> "Casey Mac" <info@srvtools.com> wrote in message
>>> news:uVeSy6e1FHA.2076@TK2MSFTNGP14.phx.gbl...
>>>> Greetings,
>>>>
>>>> What im looking for is a bit of code so that once a selection is
>>>> made (user selects text) a macro can be run that displays all the
>>>> bookmarks in the current document. The user selects the
>>>> appropirate bookmark for the selected text and then that selection
>>>> gets applied to the selected text as a hyperlink. ie #bookmark.
>>>>
>>>>
>>>> Sub Macro1()
>>>>
>>>> ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range,
>>>> Address:="", SubAddress:=" ",
>>>>
>>>> End Sub