Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Feb 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi all - I have a large document with hundreds of Text Form Fields. When you click on the Properties of one of those fields, you can see that there is a bookmark associated with it. I need a way to produce a report of all of the Text Form Fields and the associated bookmarks. Is there an easy way to do this via VBA?

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts
    [quote name='KenCris' post='767280' date='25-Mar-2009 09:19']Hi all - I have a large document with hundreds of Text Form Fields. When you click on the Properties of one of those fields, you can see that there is a bookmark associated with it. I need a way to produce a report of all of the Text Form Fields and the associated bookmarks. Is there an easy way to do this via VBA?[/quote]
    I think it depends on how much information you need. You can dump a list of the names (same as the Bookmarks) of the form fields fairly readily. The following code simply lists them in the Visual Basic Editor's "Immediate" window:

    Code:
    Sub ListFormFields()
    Dim ff As Word.FormField
    For Each ff In ActiveDocument.FormFields
    	Debug.Print ff.Name
    Next
    End Sub
    You could also check the ff.Type to limit the list to the types of fields you care about.

    However, this does not provide a lot of context, since the field captions and other related information are not readily available from the form field object itself. So... if you play with this a bit, can you more fully define your requirements?

  3. #3
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts
    [quote name='KenCris' post='767280' date='25-Mar-2009 16:19']I need a way to produce a report of all of the Text Form Fields and the associated bookmarks.[/quote]
    This VBA code will display all the bookmark names in a Message Box, depending on what you want the list could be added to the end of the document or to a new document.

    Sub ListformFields()
    Dim fldForm As FormField
    Dim strReport As String

    For Each fldForm In ActiveDocument.FormFields
    If fldForm.Type = wdFieldFormTextInput Then
    strReport = strReport & fldForm.Range.Bookmarks(1).Name & vbCrLf
    End If
    Next fldForm
    MsgBox strReport
    End Sub

  4. #4
    New Lounger
    Join Date
    Feb 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Worked wonders. Thanks for the help.

    [quote name='StuartR' post='767291' date='25-Mar-2009 16:46']This VBA code will display all the bookmark names in a Message Box, depending on what you want the list could be added to the end of the document or to a new document.

    Sub ListformFields()
    Dim fldForm As FormField
    Dim strReport As String

    For Each fldForm In ActiveDocument.FormFields
    If fldForm.Type = wdFieldFormTextInput Then
    strReport = strReport & fldForm.Range.Bookmarks(1).Name & vbCrLf
    End If
    Next fldForm
    MsgBox strReport
    End Sub
    [/quote]

Posting Permissions

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