Results 1 to 12 of 12
  1. #1
    2 Star Lounger
    Join Date
    Jun 2002
    Posts
    122
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Repeating an action in all sections of a doc (2003/SP1)

    Hi there,

    I need to create a macro for printing mail merge letters. My aim is to first of all print out a draft, simple enough, however, then I need to hide the filename and path field within the footers of all sections of the merge to print on company Letterhead (and then unhide the same field again!). Hiding the field within the first letter of the merge is easy enough, however, I'm having trouble carrying out the same for all of the sections. Can anyone help?

    Thanks!

    Violet

  2. #2
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Repeating an action in all sections of a doc (2003/SP1)

    If you're looking for a VBA/macro solution, take a look at Useful Word Procedures. The macro code shows how to get access to every section of a document. Although you don't want to update fields, you could substitute code to carry out the particular actions you're needing.

    Alan

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Repeating an action in all sections of a doc (2003/SP1)

    This is less straightforward than I had thought. You can make a Filename field hidden, but previewing or printing the document will update the field, removing the Hidden text attribute. The attached code (top be copied into a module) worked for me in a quick test. The DeleteFilenameInFooter procedure replaces all Filename fields in footers with hidden placeholder text, and RestoreFilenameInFooter reverses this. The PrintWithoutFilename macro calls DeleteFilenameInFooter, then prints out the document and finally calls RestoreFilenameInFooter.
    Attached Files Attached Files

  4. #4
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts

    Re: Repeating an action in all sections of a doc (2003/SP1)

    Hi Violet,

    Try this field coding solution in your source document's footer:
    {IF{MERGESEQ}= "" {FILENAME p}}

    Basically, what this does it to suppress the FILENAME in the merged output, but display it otherwise.

    To create the field, Press Ctrl-F9 twice, move the cursor right three spaces and press Ctrl-F9 again. This should give you a set of field braces looking like:
    { { } { } }
    Then simply fill in the text as indicated above.

    Cheers
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Repeating an action in all sections of a doc (2003/SP1)

    You never cease to amaze me with your mastery of field codes! <img src=/S/thumbup.gif border=0 alt=thumbup width=15 height=15>

  6. #6
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    5,016
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Repeating an action in all sections of a doc (2003/SP1)

    > previewing or printing the document will update the field, removing the Hidden text attribute.

    This sounds like an "accidental feature" in Word. Surely there's no good reason to make this behaviour the intention?

    Alan

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Repeating an action in all sections of a doc (2003/SP1)

    If you did this manually, you'd make the field hidden and add the * charformat switch to the field; this preserves character formatting when the field is updated.
    Somehow, this doesn't work when you set the hidden property in code. That certainly sounds like an "accidental feature"...

  8. #8
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Repeating an action in all sections of a doc (

    Hi Macropod:
    I tried this using Word 2003 & I'm not sure if I need a hotfix for fields or if it always works this way. After creating the field (but not updating it),
    1. I can perform the merge without the filename displaying in the merged results. This is true only if I don't update the IF field before doing the merge.
    2. Once I perform the first merge, the IF field is updated in the main document. From then on, performing the merge puts the filename in the footer.
    3. The field always suppresses the filename in the merged document if the IF field is placed in the body of the main document.

    Do you get the same results?

  9. #9
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts

    Re: Repeating an action in all sections of a doc (

    Edited by HansV to correct <!t>[tab]<!/t> tags.

    Hi Phil,

    I'm using Word 2000, and what I find is:
    . putting the field code into the body or the header/footer;
    . having 'Update fields' checked/unchecked in Tools|Options|Print; and
    . updating/not updating the field before running the merge,
    makes no difference - the field never displays the filename in the merged documents, but does so reliably in the main mailmerge document.

    Cheers
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  10. #10
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Repeating an action in all sections of a doc (

    Hi macropod:
    OK, I found the discrepancy. I had tested it using a catalog main document. If I change that to form letters, then it works as advertised. Apparently, when using a catalog merge, the header is merged before a field is updated. This seems to be also true for the {mergerec} field also. Any thoughts on this?

  11. #11
    Super Moderator
    Join Date
    May 2002
    Location
    Canberra, Australian Capital Territory, Australia
    Posts
    5,054
    Thanks
    2
    Thanked 417 Times in 346 Posts

    Re: Repeating an action in all sections of a doc (

    Hi Phil,

    I get the same behaviour that I reported earlier with catalog merges also.

    Cheers
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  12. #12
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Repeating an action in all sections of a doc (

    Hmmm. Each time I upgrade...new problems. <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •