#1
|
|||
|
|||
Edit Reference in Word bv VBA
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:=" " 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 Any Ideas how to add the formating to this field? It is located in the header on page 2.. thanks Andreas |
#2
|
||||
|
||||
Try:
Code:
Sub RefDemo() Application.ScreenUpdating = False ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader With Selection .EndKey Unit:=wdStory .Fields.Add .Range, wdFieldEmpty, Text = "REF T_LIEFERANTENERGAENZUNG_BERECHNUNG \* MERGEFORMAT \h", False End With Application.ScreenUpdating = True End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
Tags |
formating, vba |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Determining if an in-text table reference was created with Word's native cross reference feature | scienceguy | Excel Programming | 2 | 10-25-2021 04:44 AM |
How to edit add-ons panel in word 2010 created in word 2000 | alexxmore | Word | 2 | 03-18-2020 04:45 AM |
How do I edit my TOC to reference the section numbers instead of the page numbers??? | mikey386 | Word | 0 | 12-17-2014 02:34 PM |
Reference number and cross reference for equation numbers to match the thesis format | wmac | Word | 1 | 05-14-2013 08:54 PM |
MarkAsFinal - 'Edit Anyway' edit popup issue | GovindRS | PowerPoint | 1 | 06-20-2011 06:43 AM |