Hello,
I try to insert a Reference in Word via VBA by code:
Code:
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
Selection.EndKey Unit:=wdStory
Selection.InsertCrossReference ReferenceType:="Textmarke", ReferenceKind:=wdContentText, _
ReferenceItem:="T_LIEFERANTENERGAENZUNG_BERECHNUNG", InsertAsHyperlink:=True, _
IncludePosition:=False, SeparateNumbers:=False, SeparatorString:=" "
But I need to add the "\*MERGEFORMAT" formatting to this reference.
So I tried to loop trough all fields by code:
Code:
Dim fieldLoop As Field
Dim fieldText As String
For Each fieldLoop In ActiveDocument.Fields
If InStr(0, fieldLoop.Code.Text, "REF T_LIEFERANTENERGAENZUNG_BERECHNUNG", 1) Then
fieldText = fieldLoop.Code.Text
If InStr(1, fieldText, " \h", 1) And Not InStr(1, fieldText, " \* MERGEFORMAT", 1) Then
fieldText = fieldText & " \* MERGEFORMAT "
fieldLoop.Code.Text = fieldText
End If
End If
Next
But the Loop does not find the Reference I added before..
Any Ideas how to add the formating to this field?
It is located in the header on page 2..
thanks
Andreas