View Single Post
 
Old 04-03-2013, 09:55 AM
rusteinberg rusteinberg is offline Windows 7 64bit Office 2010 64bit
Novice
 
Join Date: Apr 2013
Posts: 1
rusteinberg is on a distinguished road
Default Macro to display help text

A co-worker shared this macro with me and I thought others might find it useful. It looks at all help text in a Word form that has text fields and spits out the text in the Status Text and Help Text into a separate document. For Section 508 (accessibility) reasons, we only use the "Legacy" text form fields where I work.
Code:
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, 4) 
    RowNum = 1 
     
    NewTable.Cell(RowNum, 1).Range.Text = "Field" 
    NewTable.Cell(RowNum, 2).Range.Text = "Location" 
    NewTable.Cell(RowNum, 3).Range.Text = "StatusText" 
    NewTable.Cell(RowNum, 4).Range.Text = "HelpText" 
    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) 
        NewTable.Cell(RowNum, 3).Range.Text = ffld.StatusText 
        NewTable.Cell(RowNum, 4).Range.Text = ffld.HelpText 
    Next ffld 
     
    Application.ScreenUpdating = True 
     
    Set NewTable = Nothing 
    Set NewDoc = Nothing 
    Set ThisDoc = Nothing 
     
End Sub

Last edited by macropod; 04-03-2013 at 02:24 PM. Reason: Added code tags & formatting
Reply With Quote