Question

I'm creating a word document from scratch as an OLE object via VBA, and have created cross-references in it. I am actually using LotusScript, but the principles of VBA should apply.

Once I have created the cross-reference, I format the entire table cell that contains it (Arial 8 Italic), but when the document is saved, the field updates its format. I know that I can set a property of the field manually by ticking the "Preserve formatting during updates " option in the Word front-end, but is there a VBA property for that?

NB, The cross-reference is to a heading, and the formatting I'm getting appears to be the same as that heading, which is not what I want.

Many thanks, Phil

Was it helpful?

Solution

I found the solution :-)

This is LotusScript, but I'm sure VB users can work out what it means. Also, I call a function and 3 subroutines, which are all self-explanatory. rg is a Range, in which I've just created the cross-reference. Due to the nature off the application, I know that the field is the first one in the range. The final line is the important one.

Set rg = getTableCell(subTable, 2, 1).Range
Dim fld As Variant
Set fld = rg.Fields(1)

Call SetItalicsOnOff(rg, True)
Call SetFontFace(rg, "Arial")
Call SetFontSize(rg, 8)
fld.Code.Text = fld.Code.Text & " \* MERGEFORMAT"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top