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

    Author
    Topic
    #374693

    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 Australia

    Viewing 0 reply threads
    Author
    Replies
    • #606933

      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.

      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
      

      Gary

      • #606950

        OK Gary, now we are cooking with gas!!

        What about introducing this?

        ActiveDocument.Comments.Add Range:=Selection.Range, Text:=strBmkName

        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

        • #607205

          Leigh,

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

          ActiveDocument.Comments.Add Range:=ActiveDocument.Bookmarks("strBmkName").Range, _
                                                                     Text:=strBmkName

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

          Gary

          • #607641

            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:

            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
            

            Gary

    Viewing 0 reply threads
    Reply To: ToolTips for Bookmarks (VBA/97-XP/All)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: