Results 1 to 7 of 7
  1. #1
    Lounger
    Join Date
    Mar 2002
    Location
    Sunnvyale, California, USA
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Hide macrobutton fields when print (Word 2000/NT4)

    Hi,
    I'm using macrobutton fields to put up a dialog that gets data for some custom properties. I'd like to hide the macrobuttons whenever the document is printed and it is not going a smoothly as I would like.

    I have tried two approaches. One is to put in my own FilePrint macro to intercept printing so I can search out and hide the macrobuttons and then unhide them after application.PrintOut finishes. Two problems-the printer icon on the toolbar doesn't fire the FilePrint macro and I don't know how to detect that the user selected File Print from the menu so I can pop up the print setup menu.

    Second approach is to use the DocumentBeforePrint event to hide the macrobuttons. I can't find what I consider a clean way to unhide them after printing, right now I'm using WindowSelectionChange to look for the macrobuttons to see if they're hidden but I'm processing events like mad. Is there a better way to detect a "DocumentAfterPrint" type of event?

    I'd appreciate any thoughts on how to address the problems I listed or if there is an easier way to prevent macrobuttons from printing (note: I don't want a button that you click on to print the document)?

    Thanks,
    Eric

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Hide macrobutton fields when print (Word 2000/NT4)

    One of these parts is easy -

    > the printer icon on the toolbar doesn't fire the FilePrint macro

    this runs the command FilePrintDefault, which you can intercept with a Sub procedure of the same name.

    My overall thought is: what if you make the buttons hidden and toggle View>Hidden Text TRUE, Print>Hidden Text FALSE in the Tools>Options... dialog?

  3. #3
    Lounger
    Join Date
    Mar 2002
    Location
    Sunnvyale, California, USA
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hide macrobutton fields when print (Word 2000/NT4)

    Hi,
    Sorry to be so long in getting back. I ended up having FilePrint and FilePrintDefault macros that hide the macrobuttons, prints and then unhides them.

    Thanks,
    Eric

  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: Hide macrobutton fields when print (Word 2000/NT4)

    Hi Eric,

    For a non-macro solution, you could modify the MACROBUTTON field like:
    {MACROBUTTON NoMacro {IF{PRINTDATE @ yyyyMMddHHmm}={DATE @ yyyyMMddHHmm} "" "No Macro Button"}}
    This hides the button at print time, and F9 or print preview restores it afterwards. The only limitation is that the PRINTDATE field doesn't support seconds (Wd2K, SR1), so you might have to wait up to a minute before you can restore the field.

    Cheers
    Cheers,

    Paul Edstein
    [MS MVP - Word]

  5. #5
    Lounger
    Join Date
    Mar 2002
    Location
    Sunnvyale, California, USA
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hide macrobutton fields when print (Word 2000/NT4)

    Hi,
    Interesting concept, unfortunately I wasn't able to get to the first step of entering your field. I hit ctrl-F9 and pasted in the string between {} from your post and I get "DisplayText cannot span more than one line!". Syntax problem?

    Thanks,
    Eric

  6. #6
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Hide macrobutton fields when print (Word 2000/NT4)

    You need to convert all of the internal braces to field code braces, too:

    { MACROBUTTON NoMacro { IF { PRINTDATE @ yyyyMMddHHmm } = { DATE @ yyyyMMddHHmm } "" "No Macro Button" } }

    I just experimented and discovered that if you select, say, PRINTDATE @ yyyyMMddHHmm and press Ctrl+F9, it surrounds it with field braces. So you should be able to do it fairly quickly (and delete the leftover "text" braces).

    And it works!

  7. #7
    Lounger
    Join Date
    Mar 2002
    Location
    Sunnvyale, California, USA
    Posts
    25
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hide macrobutton fields when print (Word 2000/NT4)

    Hi,
    That did it. It is a neat effect that I stored away but for this particular problem I think grabbing the print actions works better, especially since I stuck a couple of other operations in the macros too.

    Thanks,
    Eric

Posting Permissions

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