Word

List Form Field Names in Separate Document

Ease of Use

Easy

Version tested with

2000 

Submitted by:

TonyJollans

Description:

Provides a list of all form field names by placing them in a new document, along with their location by page and line number. 

Discussion:

Handy tool so you don't have to check each field. 

Code:

instructions for use

			

Sub ListFormFields() Dim ThisDoc As Document, NewDoc As Document Dim NewTable As Table Dim RowNum As Long Dim ffld As FormField Application.ScreenUpdating = False Set ThisDoc = ActiveDocument Set NewDoc = Documents.Add Set NewTable = NewDoc.Tables.Add(NewDoc.Content, ThisDoc.Content.FormFields.Count + 1, 2) RowNum = 1 NewTable.Cell(RowNum, 1).Range.Text = "Field" NewTable.Cell(RowNum, 2).Range.Text = "Location" NewTable.Rows(1).Range.Font.Bold = True NewTable.Rows(1).HeadingFormat = True For Each ffld In ThisDoc.Content.FormFields RowNum = RowNum + 1 NewTable.Cell(RowNum, 1).Range.Text = ffld.Name NewTable.Cell(RowNum, 2).Range.Text = _ "Page " & ThisDoc.Range(ffld.Range.Start, ffld.Range.Start).Information(wdActiveEndPageNumber) _ & ", Line " & ffld.Range.Information(wdFirstCharacterLineNumber) Next ffld Application.ScreenUpdating = True Set NewTable = Nothing Set NewDoc = Nothing Set ThisDoc = Nothing End Sub

How to use:

  1. Copy the code above.
  2. Open the document that contains the form fields.
  3. Hit Alt+F11 to open the Visual Basic Editor (VBE).
  4. From the menu, hit Insert-Module.
  5. Paste the code into the window that appears at right.
  6. Hit the save diskette icon and close the VBE.
 

Test the code:

  1. Hit Tools-Macro, Macros, and double-click ListFormFields.
 

Sample File:

formfields.zip 5.57KB 

Approved by mdmackillop


This entry has been viewed 74 times.

Please read our Legal Information and Privacy Policy
Copyright @2004 - 2020 VBA Express