I want to insert field code like {SEQ seq \h} when I apply “Heading 1” style to some text.
I think it is related to vba and can be divide into two parts.
1.find the event which would be triggered after Paragraph Style changed.
2.insert field code at head of the paragraph.
question 2 can be achieved by
.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:="SEQ SEQ_ID\* Arabic \* MERGEFORMAT", PreserveFormatting:=True
question 1 is hard to find. Any one have done that before?
You may be able to capture the
WindowSelectionChangeevent. However, you will have to write your own handler for it. Refer to this website to get you started:Writing application event procedures