none
Capture print problem in Word 2010 RRS feed

  • Question

  • Hello, i had some code in Word 2007 that intercepted the print command using the built in command FilePrint. This would call a userform with various options such as print to letterhead, which would hide any logos etc, print the doc and then unhide the logo.

    Of course now with 2010 you cannot use the FilePrint command but must instead use the application event "DocumentBeforePrint". This is ok to intercept the print command and run some code prior, but it does not allow for code to run after the print command executes.

    Does any one know of a way around this. Any help would be very much appreciated.

    Regards
    David 

    Wednesday, August 10, 2011 8:23 AM

Answers

  • <argh> Right, I'd forgotten about that. PITA, that change <sigh>

    By coincidence, I've been doing some work with Backstage the last couple of days, re-reading the documentation, and came across the FAQ in "Introduction to the Office 2010 Backstage View for Developers" where they discuss repurposing of definitive command buttons, fast command buttons and tabs by changing onAction. I'd say that the PRINT button in the Print Tab falls into the category "definitive command". The answer is:

    "It is not possible to override these commands from the custom UI XML markup or by using the object model."

    It goes on to recommend the event (as you say) or to hide the built-in UI and rebuild it from scratch with custom commands. Since this is VBA you should also be able to "re-map" the Ctrl+P key combination to your own code. It looks like you can pick up the other elements in that tab via idMso.


    Cindy Meister, VSTO/Word MVP
    Thursday, August 11, 2011 2:45 PM
    Moderator

All replies

  • Hi David

    The other way is to place a Ribbon customization in the document or template that has a <commands> section with a <command idMso="FilePrint" onAction="YourMacroName" />


    Cindy Meister, VSTO/Word MVP
    Wednesday, August 10, 2011 2:36 PM
    Moderator
  • Hi Cindy, this works ok in Word 2007 but not 2010, i'm guessing something to do with the print functionality now being in the backstage area.
    Thursday, August 11, 2011 12:35 AM
  • <argh> Right, I'd forgotten about that. PITA, that change <sigh>

    By coincidence, I've been doing some work with Backstage the last couple of days, re-reading the documentation, and came across the FAQ in "Introduction to the Office 2010 Backstage View for Developers" where they discuss repurposing of definitive command buttons, fast command buttons and tabs by changing onAction. I'd say that the PRINT button in the Print Tab falls into the category "definitive command". The answer is:

    "It is not possible to override these commands from the custom UI XML markup or by using the object model."

    It goes on to recommend the event (as you say) or to hide the built-in UI and rebuild it from scratch with custom commands. Since this is VBA you should also be able to "re-map" the Ctrl+P key combination to your own code. It looks like you can pick up the other elements in that tab via idMso.


    Cindy Meister, VSTO/Word MVP
    Thursday, August 11, 2011 2:45 PM
    Moderator
  • Hi Cindy, I read the same thing and that's what I have ended up doing, in fact it works really well.

    Thanks for your time, appreciate it.

    Cheers
    David 

    Thursday, August 11, 2011 11:49 PM
  • Is Microsoft going to address this, or do we throw away months worth of 2007 deveopment because there aren't any commands that are equvilant.
    Monday, November 21, 2011 4:42 PM