• Macro populates Header and TOC (Word XP)

    Author
    Topic
    #399912

    Duh….
    I need to edit the styleref value.
    How are the switches applied in the editor of the field codes of the header properties?
    Any help would be appreciated

    Viewing 2 reply threads
    Author
    Replies
    • #776267

      I’m trying to adjust the macro in the attached doc to populate the headers with a second level of numbering.
      They want the headers to drill down to the next level (i.e. the alpha chars).
      The attached 1 page sample would have values of 100.1 to 110.2. A
      Thanks for your help
      blackteeth

    • #776268

      I’m trying to adjust the macro in the attached doc to populate the headers with a second level of numbering.
      They want the headers to drill down to the next level (i.e. the alpha chars).
      The attached 1 page sample would have values of 100.1 to 110.2. A
      Thanks for your help
      blackteeth

    • #776428

      Are you creating the header from code, or manually.

      If manually then Insert > Field > Styleref and the switches appear as selections on the right.
      If by code then you can modify the value of fld.Code.Text

      StuartR

      • #776431

        The person responsible does it manually through the field codes element in the header.
        I don’t know if they’ll allow me to write code because they could never maintain it.
        It looks like the w slash is what I need according to documentation, but I don’t see any bookmarks in the document.
        Do I need to populate the bookmarks?
        Thanks

        • #776510

          What you are trying to do falls into the too hard basket for Word because you are trying to combine the paragraph numbers from two different paragraphs into the one styleref field (possibly a nested one).

          A macro solution will need to put a section break between every page, examine the first and preceding numbered paragraphs for each section (page) to find out the style names, examine the last and preceding numbered paragraphs for each section (page) and then use this information to customise the header for that section.

          Your best solution would be to negotiate with the document owner on why this is not sensible in its present form.

          If you used the full paragraph numbering on every paragraph eg the A becomes 101.1.A then the task becomes somewhat easier but it is still far from easy unless the SAME style is used for EVERY numbered paragraph.

          If you come up with a workable solution, I would love to hear what it is because I could probably use it myself – I know I’ve been asked for something like this before.

          • #776826

            I saw a switch ( w ) which places a bookmark in the heading.
            Can I use them in conjunction?
            Also, with the ‘=Formula’ can I place a nested if statement?

            I’m thinking this is really looking like a programming venture.
            Has anyone encountered something like this?

          • #776827

            I saw a switch ( w ) which places a bookmark in the heading.
            Can I use them in conjunction?
            Also, with the ‘=Formula’ can I place a nested if statement?

            I’m thinking this is really looking like a programming venture.
            Has anyone encountered something like this?

        • #776511

          What you are trying to do falls into the too hard basket for Word because you are trying to combine the paragraph numbers from two different paragraphs into the one styleref field (possibly a nested one).

          A macro solution will need to put a section break between every page, examine the first and preceding numbered paragraphs for each section (page) to find out the style names, examine the last and preceding numbered paragraphs for each section (page) and then use this information to customise the header for that section.

          Your best solution would be to negotiate with the document owner on why this is not sensible in its present form.

          If you used the full paragraph numbering on every paragraph eg the A becomes 101.1.A then the task becomes somewhat easier but it is still far from easy unless the SAME style is used for EVERY numbered paragraph.

          If you come up with a workable solution, I would love to hear what it is because I could probably use it myself – I know I’ve been asked for something like this before.

      • #776432

        The person responsible does it manually through the field codes element in the header.
        I don’t know if they’ll allow me to write code because they could never maintain it.
        It looks like the w slash is what I need according to documentation, but I don’t see any bookmarks in the document.
        Do I need to populate the bookmarks?
        Thanks

      • #776858

        OK, I’m thinking that I’m going to have to code this in order to get it done as soon as possible.
        What type of loop would you recommend to capture the values for the variables?
        Also, how would I generate the run-time pagination function?
        If I’m getting this right, I need to populate each fld.code.txt in a run-time pagination call.
        Is there a way to distinguish which is the top and which is the bottom field?
        I mean, do they have separate names or am I creating those too?
        I think I’ll have a look in the object browser, I guess. compute

      • #776859

        OK, I’m thinking that I’m going to have to code this in order to get it done as soon as possible.
        What type of loop would you recommend to capture the values for the variables?
        Also, how would I generate the run-time pagination function?
        If I’m getting this right, I need to populate each fld.code.txt in a run-time pagination call.
        Is there a way to distinguish which is the top and which is the bottom field?
        I mean, do they have separate names or am I creating those too?
        I think I’ll have a look in the object browser, I guess. compute

        • #777011

          I’m inclined to agree with Andrew on this one. The easiest way to code this will be to change the level 4 header so it includes the previous levels and then use a standard StyleRef

          StuartR

        • #777012

          I’m inclined to agree with Andrew on this one. The easiest way to code this will be to change the level 4 header so it includes the previous levels and then use a standard StyleRef

          StuartR

    Viewing 2 reply threads
    Reply To: Macro populates Header and TOC (Word XP)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: