I fail to create nested fields. I would like my vba code to insert
following formula into a table cell:
{={ NUMPAGES \* MERGEFORMAT }+3}
any hints greatly appreciated!
Luc
Hi Luc,
There are many ways you could do this, and this is only one:
Selection.Fields.Add _
Range:=Selection.Range, _
Type:=wdFieldNumPages, _
Text:="", _
PreserveFormatting:=True
Set oRng = Selection.Paragraphs(1).Range
With oRng
.MoveEnd unit:=wdCharacter, Count:=-1
.InsertBefore Text:="="
.InsertAfter Text:="+3"
.Select
End With
With Selection.Fields
.Add _
Range:=Selection.Range, _
Type:=wdFieldEmpty, _
PreserveFormatting:=False
.Update
End With
HTH,
Dave
> I fail to create nested fields. I would like my vba code to insert
> following formula into a table cell:
[quoted text clipped - 3 lines]
> any hints greatly appreciated!
> Luc
Luc Benninger - 28 Feb 2005 14:43 GMT
Dave, thanks a lot!
> Hi Luc,
>
[quoted text clipped - 31 lines]
>>any hints greatly appreciated!
>>Luc
Jay Freedman - 28 Feb 2005 15:10 GMT
Hi Luc,
There's more on this topic at
http://word.mvps.org/FAQs/MacrosVBA/NestedFieldsWithVBA.htm, including how
to work with nested fields in headers and footers (which is where I suspect
your field is going).

Signature
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
> Dave, thanks a lot!
>
[quoted text clipped - 33 lines]
>>> any hints greatly appreciated!
>>> Luc
Another alternative is to create your field manually, save it as an AutoText
entry, and use code to insert the AutoText.

Signature
Charles Kenyon
Word New User FAQ & Web Directory: http://addbalance.com/word
Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide
See also the MVP FAQ: http://www.mvps.org/word which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
>I fail to create nested fields. I would like my vba code to insert
>following formula into a table cell:
[quoted text clipped - 3 lines]
> any hints greatly appreciated!
> Luc