It is common practice to Insert, Fields into a document and then
Insert,Fields within them (nested).
For example:
{ MACROBUTTON TestMacro { SYMBOL 254 \a \f Wingdings \s 12 \* MERGEFORMAT
}}
I know that Word VBA can also be used to add a field to a document.
For example:
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, _
Text:="MACROBUTTON TestMacro X ", _
PreserveFormatting:=False
or
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, _
Text:="SYMBOL 254 \a \f Wingdings \s 12 ", PreserveFormatting:=True
BUT is it possible for Word VBA to add "nested" fields to a document?
As usual, any help would be greatly appreciated.
Paul J
Russ - 20 Jul 2007 09:32 GMT
Paul,
Here is a code snippet where I was creating a nested field to divide the
number of words in a document by 2:
Selection.fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _
"INFO NumWords", PreserveFormatting:=False
Selection.PreviousField
Selection.fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, _
PreserveFormatting:=False
Selection.TypeText Text:="="
Selection.NextField
Selection.Collapse direction:=wdCollapseEnd
Selection.TypeText Text:="/2"
Selection.Collapse direction:=wdCollapseEnd
'Selection.MoveRight Unit:=wdCharacter, Count:=2
Selection.PreviousField.Update
> It is common practice to Insert, Fields into a document and then
> Insert,Fields within them (nested).
[quoted text clipped - 22 lines]
>
> Paul J

Signature
Russ
drsmN0SPAMikleAThotmailD0Tcom.INVALID
Jay Freedman - 20 Jul 2007 14:26 GMT
Another example of similar code is at
http://www.word.mvps.org/FAQs/MacrosVBA/NestedFieldsWithVBA.htm.

Signature
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
> Paul,
> Here is a code snippet where I was creating a nested field to divide
[quoted text clipped - 40 lines]
>>
>> Paul J
Paul J - 20 Jul 2007 14:34 GMT
Russ & Jay
Your help is much appreciated.
Paul J
> Another example of similar code is at
> http://www.word.mvps.org/FAQs/MacrosVBA/NestedFieldsWithVBA.htm.
[quoted text clipped - 43 lines]
> >>
> >> Paul J