Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Brisbane, Australia
    Posts
    245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ToolTips for Bookmarks (VBA/97-XP/All)

    In MS Word I, like many others create templates that a user initiates by choosing a button on a custom toolbar. This brings up a userform that is completed by the user and the subsequent data is passed to the template usually at Bookmarks.

    My question is; Has anyone else seen the need for a ToolTip to come up when you hover over a Bookmark with the mouse?

    I find it difficult to check that the names that I have created are indeed the ones that the code is supposed to pass the info to. (I usually use the keyboard shortcut Ctrl+Shift+F5 to display the Bookmark dialog but it would be simpler (and save may hair from going grey as quickly) if a ToolTip could 'reveal' the Bookmark name).

    Any suggestions, MS Word aficionados?

    Leigh <img src=/S/flags/Australia.gif border=0 alt=Australia width=30 height=18>

  2. #2
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: ToolTips for Bookmarks (VBA/97-XP/All)

    Leigh,

    My workaround for this is the following macro, which types the name of each bookmark in the document, immediately after the bookmark.
    Only caution is to never run this macro on the template itself, but rather on a document based on the template (creating a new document based on the template, while holding shift, will create a new document with all the original bookmarks preserved).

    Although not as handy as an onscreen tooltip, you can print out a hard copy of the document containing the bookmark names - helpful while working with the template code.

    <pre>Public Sub TypeEachBmkName()
    Dim aBmk As Bookmark
    Dim strBmkName As String

    If Documents.Count > 0 Then
    For Each aBmk In ActiveDocument.Bookmarks
    strBmkName = aBmk.Name
    aBmk.Range.InsertAfter strBmkName
    Next aBmk
    End If
    End Sub
    </pre>

    Gary

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Brisbane, Australia
    Posts
    245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ToolTips for Bookmarks (VBA/97-XP/All)

    OK Gary, now we are cooking with gas!!

    What about introducing this? <pre>ActiveDocument.Comments.Add Range:=Selection.Range, Text:=strBmkName</pre>


    I have tried but can't seem to make the Comment appear at any point other than the current cursor point in the document. What it needs to do of course is to move the selection to the Bookmark, select it then display the Comment.

    Suggestions? Thanks

  4. #4
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: ToolTips for Bookmarks (VBA/97-XP/All)

    Leigh,

    Forgive me for not taking the time to test this, but what about:

    <pre>ActiveDocument.Comments.Add Range:=ActiveDocument.Bookmarks("strBmkName").Rang e, _
    Text:=strBmkName</pre>

    (I've had to add the line continuation character to get this to fit in the window.)

    Gary

  5. #5
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: ToolTips for Bookmarks (VBA/97-XP/All)

    Just had a chance to test this - and there was a typo in the snippet I posted.
    The following does work - although the range the comment gets applied to may not be what you expect - couldn't work out (in the brief time I spent) how to get the comment to apply only to the original bookmark range. Anyway:

    <pre>Public Sub TypeEachBmkName()
    'Types name of bookmark immediately after each bookmark
    ' and applies a comment (containing the name of the bookmark)
    ' to each bookmark
    Dim aBmk As Bookmark
    Dim strBmkName As String

    If Documents.Count > 0 Then
    For Each aBmk In ActiveDocument.Bookmarks
    strBmkName = aBmk.Name
    aBmk.Range.InsertAfter strBmkName
    ActiveDocument.Comments.Add _
    Range:=aBmk.Range, _
    Text:=strBmkName
    Next aBmk
    End If
    End Sub
    </pre>

    Gary

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •