Hi Jezebel,
Yes, you're right about both issues. To address the first issue, the
following code would work:
Sub ListFields()
Dim oFld As Field
If ActiveDocument.Fields.Count > 0 Then
For Each oFld In ActiveDocument.Fields
With Selection
.EndKey Unit:=wdStory
.InsertAfter vbCrLf
.EndKey Unit:=wdStory
.TypeText Text:="{" & oFld.Code & "}, " & oFld.Result
End With
Next oFld
End If
End Sub
To address the second issue, additional code could be used to loop through
headers, footers & shapes as with the following field updating macro (which
might be useful to run before running ListFields):
Sub RefreshFields()
Dim oSection As Section, shp as Shape, oHeadFoot As HeaderFooter
ActiveDocument.Fields.Update
For Each oSection In ActiveDocument.Sections
For Each oHeadFoot In oSection.Footers
If Not oHeadFoot.LinkToPrevious Then oHeadFoot.Range.Fields.Update
Next
For Each oHeadFoot In oSection.Headers
If Not oHeadFoot.LinkToPrevious Then oHeadFoot.Range.Fields.Update
Next
Next
If ActiveDocument.Shapes.Count > 0 Then
For Each shp In doc.Shapes
With shp.TextFrame
If .HasText Then .TextRange.Fields.Update
End With
Next
End If
End Sub
Cheers