Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / February 2006

Tip: Looking for answers? Try searching our database.

Inserting an expression field

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Peter - 03 Feb 2006 18:59 GMT
I have "Page X of Y" in a header where Y is normally a field of type
wdFieldNumPages. I have modified this field manually by inserting an
expression field (i.e. type wdFieldExpression) that reads "= expression - 3"
where expression in this case is the NumPages field. This works as intended
and I can create this manually. I need to create it programmatically however
because the -3 could be -1 or -2, etc. I cannot find any documentation on how
to specifiy the expression when creating a field of this type. Also, when I
look this field I created manually from the locals window in a macro, I can
see that the NUMPAGES field is contained within the expression field.
Does anyone have any idea how I can do this programmatically?

Thanks!
Jay Freedman - 03 Feb 2006 20:11 GMT
> I have "Page X of Y" in a header where Y is normally a field of type
> wdFieldNumPages. I have modified this field manually by inserting an
[quoted text clipped - 9 lines]
>
> Thanks!

It isn't easy. See
http://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.

Peter - 03 Feb 2006 20:45 GMT
Thank you very much. I have read the article and it is very informative. You
are right that this is not easy but, I found an easier way to accomplish what
I needed. Instead of hardcoding the number to subtract from NUMPAGES (and
subsequently update it in VBA, I substituted a DOCVARIABLE field. I did this
manually in the template. Now my macro simply updates the DOCVARIABLE and
updates the fields.

Thanks again!
Peter

> > I have "Page X of Y" in a header where Y is normally a field of type
> > wdFieldNumPages. I have modified this field manually by inserting an
[quoted text clipped - 12 lines]
> It isn't easy. See
> http://word.mvps.org/FAQs/MacrosVBA/NestedFieldsWithVBA.htm.

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.