Insert Cross Reference by vba and add \* Charformat to it
Posted on 2010-09-18
I'm inserting cross-references into a document from a userform, eg of the insert method below.
Selection.InsertCrossReference ReferenceType:=strLabel, _
When it puts in a Table Caption for instance it inserts the formatting of the caption which is bolded. I've tried a few ways of getting around this (like applying unbold) but on update it reverts back to bold even with unbold character style applied. Then I stumbled across something tonight which I can add into the cross reference field that has been created. And that is \* Charformat . But I can't work out how to get it to automatically come in like this. At the moment I have to right-click on the cross-reference and then click Edit Field > Field Codes > Options > Field Specific Switches > then I paste \* Charformat down in the field code text box. It is working when I do it this way but I need to set that step by code.
Experts how can I do this through VBA code as this is a very long-winded step?