none
Cannot nest field code ADVANCE in Word 2007 RRS feed

  • Question

  • Hello,

    I would like to use the ADVANCE field code in a dynamic way e.g with STYLEREF to obtain its parameter value.

    Things I tried:

    { ADVANCE  \x { STYLEREF  <some-style>}} (referencing a number formatted in that specific style)

    { ADVANCE  \x { NUMCHARS }} (to see whether a source with an int value produces some result)

    { ADVANCE  \x { =(10+5) } } (again to see if it yields some result a all)

    I the followin link saw square brackets being used to nest field codes (e.g {<field code> [{<field code>}] }) but that does not seem to work for me either.

    http://social.msdn.microsoft.com/Forums/eu/worddev/thread/8802133f-33ff-42fd-a2b4-c303580e57b4

    If any result at all was apparent then it was an "Error!" message.

    So I guess what my question comes down to would be, whether it is possible at all to nest field codes in such a manner.

    Thanks,

    Michael

     

    Tuesday, February 8, 2011 12:43 PM

Answers

  • In principle I don't think there's any reason you shouldn't be able to do it - and some fields can certainlky be nested, but I can't make this work. ADVANCE fields were, I believe, originally created as an aid to people migrating from WordPerfect, so perhaps they have limited capability - I don't know, and, of course, none of this is documented :-(
     

    Enjoy,
    Tony
    www.WordArticles.com
    • Marked as answer by mlh76 Monday, February 14, 2011 3:33 PM
    Thursday, February 10, 2011 5:53 PM
  • Hi Michael

    I think the problem could be the order in which the fields are executed / evaluated. Both the Print and Advance fields change the page layout, not the page content. And I seem to recall - very vaguely, very long ago - that these evaluate before the other fields' results are ready...


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by mlh76 Monday, February 14, 2011 3:33 PM
    Thursday, February 10, 2011 6:06 PM
    Moderator

All replies

  • Hello Michael,

    Thanks for posting. Would you please clarify one point for us? Are you looking for a way in code or by UI (manually)?

    If it is the latter, here are some resources about advance field. Please check them and see if they could help you.

    WD: Using the ADVANCE Field in Word:
    http://support.microsoft.com/kb/118637.

    WD: Err Msg: "Fields Are Nested Too Deeply" in Mail Merge:
    http://support.microsoft.com/kb/189015.

    If you have any concern on this post, just feel free to follow up. Have a nice day.


    Bessie Zhao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, February 10, 2011 9:19 AM
  • Hello,

    Thanks for your reply.

    As long as I cannot make it work manually inserting the field codes by code is secondary. So we can ommit the code perspective for now.

    Concearning the usage of the ADVANCE field I do not have any problems using it in a static manner, but this is not what I want. What I want to do is placing an ADVANCE field in a Word document's header and dynamically set its value from within the document's content via a STYLEREF field, or anything else that lets me set the parameter value of the field relative to the document's content on the current page.

    I am a little confused on the topic of nesting fields. Most resources I find - as the one in the link you included - treat nesting IFs, but what I want is setting a field code's parameter value via an inner second field code e.g. {ADVANCE \x {STYLEREF Heading9}} with the text referenced by STYLEREF being a numeric value. This I do not seem to be getting to work. I tried numerous variants for the source of the inner field e.g. the character count, calculating a value with a formula and so on.

    In short: is it possible to pass the result value from an inner field as parameter to an outer field? If yes how?

    Thanks,

    Michael

     

    Thursday, February 10, 2011 3:46 PM
  • In principle I don't think there's any reason you shouldn't be able to do it - and some fields can certainlky be nested, but I can't make this work. ADVANCE fields were, I believe, originally created as an aid to people migrating from WordPerfect, so perhaps they have limited capability - I don't know, and, of course, none of this is documented :-(
     

    Enjoy,
    Tony
    www.WordArticles.com
    • Marked as answer by mlh76 Monday, February 14, 2011 3:33 PM
    Thursday, February 10, 2011 5:53 PM
  • Hi Michael

    I think the problem could be the order in which the fields are executed / evaluated. Both the Print and Advance fields change the page layout, not the page content. And I seem to recall - very vaguely, very long ago - that these evaluate before the other fields' results are ready...


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by mlh76 Monday, February 14, 2011 3:33 PM
    Thursday, February 10, 2011 6:06 PM
    Moderator