none
Fields in Microsoft word RRS feed

  • Question

  • Hi,

    I would like to use Fields in MS-Word to get the number of pages between two page breaks.  What FieldCode Should I use for this?

    Also is there a way to update all the Fields in the Document explictily. By default the fields are updated before printing but I would like to update all the Fields at the same time?

    Any help is greatly appreciated,

    Thanks,

     

     

    Wednesday, November 17, 2010 5:19 AM

Answers

  • Hi rythm

    The only field that could help you get the number of pages between two page breaks would be the field SectionPages. For that, you'd need to use a Section Break of the type Next Page for the page breaks (instead of pressing ENTER).

    Besides that, the only approach I know of would be to insert a PAGE field immediately after the first and before the last page break. Select each and insert a Bookmark. format the field as "hidden". The insert a calculation field and subtract the first field's result from the second's.

    So, if I bookmark the first Page field as SecStart and the second as SecEnd:

    { = {Ref SecEnd } - {Ref SecStart} \* CharFormat }

    For updating all fields (and otherwise doing something "everywhere" in a document) see, for example, this page:

    http://gregmaxey.mvps.org/Field_Macros.htm


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by rythm20 Monday, November 22, 2010 5:41 AM
    Wednesday, November 17, 2010 6:57 AM
    Moderator

All replies

  • Hi rythm

    The only field that could help you get the number of pages between two page breaks would be the field SectionPages. For that, you'd need to use a Section Break of the type Next Page for the page breaks (instead of pressing ENTER).

    Besides that, the only approach I know of would be to insert a PAGE field immediately after the first and before the last page break. Select each and insert a Bookmark. format the field as "hidden". The insert a calculation field and subtract the first field's result from the second's.

    So, if I bookmark the first Page field as SecStart and the second as SecEnd:

    { = {Ref SecEnd } - {Ref SecStart} \* CharFormat }

    For updating all fields (and otherwise doing something "everywhere" in a document) see, for example, this page:

    http://gregmaxey.mvps.org/Field_Macros.htm


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by rythm20 Monday, November 22, 2010 5:41 AM
    Wednesday, November 17, 2010 6:57 AM
    Moderator
  • Hi (rythm20?),

    I am not sure about your 1st question, maybe you can use Information(wdActiveEndPageNumber) if you have range objects for the "containing page breaks" (see http://msdn.microsoft.com/en-us/library/aa169048(office.10).aspx).

     

    With regard to updating all fields, please see this helps: http://msdn.microsoft.com/en-us/library/ff196072.aspx


    TX Guy
    Wednesday, November 17, 2010 7:15 AM