The Index property returns the index number of a data field in a collection. The first item in the collection has an index number of 1. This code fails if there are any data fields that are not part of the document default and their values are not set to the shape.
Examples:
The following VBA example shows the list of all data fields defined for the active document and the corresponding data values for the currently selected shape.
Sub Test()
Dim s As String
Dim df As DataField
s = "Data Fields available:" & vbCr
For Each df In ActiveDocument.DataFields
s = s & vbCr & df.Name & " = " & ActiveShape.ObjectData(df.Index).Value
Next df
MsgBox s
End Sub