• Export or create a list of the bookmarks in a document

    Home » Forums » AskWoody support » Productivity software by function » MS Word and word processing help » Export or create a list of the bookmarks in a document

    Author
    Topic
    #460038

    Is there a quick way of exporting or creating a list of the bookmarks in a document?

    I need to use the bookmarks in hyperlinks in another application, and I don’t know any other way other than opening the Insert / Bookmarks dialog, and copying one by one.

    Help appreciated!

    Viewing 1 reply thread
    Author
    Replies
    • #1161752

      Is there a quick way of exporting or creating a list of the bookmarks in a document?

      I need to use the bookmarks in hyperlinks in another application, and I don’t know any other way other than opening the Insert / Bookmarks dialog, and copying one by one.

      Help appreciated!

      Hi gchutrau,

      The following macro generates a list of all bookmarks at the end of the active document, and displays their contents:

      Code:
      Sub ListBkMrks()
      Dim oBkMrk As Bookmark
      If ActiveDocument.Bookmarks.Count > 0 Then
        With Selection
      	.EndKey Unit:=wdStory
      	.TypeText Text:=vbCrLf & "Bookmark" & vbTab & "Contents"
      	For Each oBkMrk In ActiveDocument.Bookmarks
      	  .TypeText Text:=vbCrLf & oBkMrk.Name & vbTab & oBkMrk.Range.Text
      	Next oBkMrk
        End With
      End If
      End Sub

      Cheers,
      Paul Edstein
      [Fmr MS MVP - Word]

    • #1161753

      The following macro creates a list of the names of the bookmarks in the active document; the list is created in a new document that you can print or save.

      Code:
      Sub ListBookmarks()
        Dim docSource As Document
        Dim docTarget As Document
        Dim bmk As Bookmark
        Set docSource = ActiveDocument
        Set docTarget = Documents.Add
        For Each bmk In docSource.Bookmarks
      	With docTarget.Content
      	  .InsertAfter bmk.Name
      	  .InsertParagraphAfter
      	End With
        Next bmk
      End Sub

      If you save the macro in your Normal.dot (Normal.dotm for Word 2007), you can call it from any document.

      • #1161774

        The following macro creates a list of the names of the bookmarks in the active document; the list is created in a new document that you can print or save.

        Code:
        Sub ListBookmarks()
          Dim docSource As Document
          Dim docTarget As Document
          Dim bmk As Bookmark
          Set docSource = ActiveDocument
          Set docTarget = Documents.Add
          For Each bmk In docSource.Bookmarks
        	With docTarget.Content
        	  .InsertAfter bmk.Name
        	  .InsertParagraphAfter
        	End With
          Next bmk
        End Sub

        If you save the macro in your Normal.dot (Normal.dotm for Word 2007), you can call it from any document.

        Cool! Works perfect!! Thank you.

    Viewing 1 reply thread
    Reply To: Export or create a list of the bookmarks in a document

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

    Your information: