Results 1 to 4 of 4

Thread: Getting list of bookmarks from a Word file

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2001
    Posts
    2

    Getting list of bookmarks from a Word file

    Hi,

    Does anyone know how to programmtically get a list of bookmarks within a named Word document?

    thanks,
    Tom

  2. #2
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    VB Code:
    1. '----------------------------------------
    2. '- Name:    peet
    3. '- Email:   [email][email protected][/email]
    4. '- Web:
    5. '- Company: PvP
    6. '----------------------------------------
    7. '- Notes:   Lists all bookmarks and fiels
    8. '       found in a word doc.
    9. '----------------------------------------
    10.  
    11. 'To test this, Create a new vb project. Add two listboxes and a command button to the form.
    12. Option Explicit
    13. Private objWord As Word.Application
    14. Private wd As Word.Document
    15.  
    16. Private Sub Command1_Click()
    17.     Dim i As Integer
    18.    
    19.     If objWord Is Nothing Then
    20.         Set objWord = CreateObject("Word.Application")
    21.     Else
    22.         Set objWord = GetObject(, "Word.Application")
    23.     End If
    24.     DoEvents
    25.     Set wd = objWord.Documents.Open("c:\Test.doc")
    26.    
    27.     List1.Clear
    28.     List2.Clear
    29.    
    30.     For i = 1 To wd.FormFields.Count
    31.         List1.AddItem wd.FormFields(i).Name
    32.     Next
    33.     For i = 1 To wd.Bookmarks.Count
    34.         List2.AddItem wd.Bookmarks(i).Name
    35.     Next
    36.     objWord.Quit False
    37. End Sub
    -= a peet post =-

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2001
    Posts
    2

    thank you!!

    cheers mate!
    Tom

  4. #4
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    Your welcome Tom
    -= a peet post =-

Posting Permissions

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



Click Here to Expand Forum to Full Width