none
Hiding underline while printing and PrintPreview RRS feed

  • Question

  • Hi,

    We have developed MS Word plugin which does some parsing and underline hyperlink in the document.

    We are looking at following -

    1. when the print is triggered, remove the underline so that the underline should not go to printer, once print is completed the underline should appear back.
    2. When user is in Print Preview mode,  remove these underline so that the underline should not go to printer, once user closes this Print Preview, underline should appear back.

    We are able to remove the underline since we get event "DocumentBeforePrint" but we are not able get back since we do not have "DocumentAfterPrint" or some other event. Please guide me how we can do this.

    Best Regards,
    Matri.


    Tuesday, November 6, 2012 2:04 AM

Answers

  • Hi Matri

    For Word 2007 and Word 2010 you'd have the option of re-purposing the FilePrint (and FilePrintPreview) commands via a Ribbon XML customization that's part of your Add-in.

    In the <commands> section of the Ribbon XML you'd need a <command> element for each command you want to re-purpose, with the idMso set to that of the command in question. In this case you would not also use DocumentBeforePrint.

    In the callback code for the command simply cancel the default, perform the steps you want to execute prior to the command itself being called, then send the PrintOut command for the document, and afterwards comes the code you want to execute after printing has taken place. Note that it will be necessary for you to make sure Background Printing is disabled.

    For Word 2003, this approach is not possible except using VBA, where you'd create a macro named FilePrint (and one for FilePrintPreview).

    In 2013 there is no equivalent option available due to printing have been incorporated into Backstage. For 2013 you'd need to create your own Print tab in order to take control of printing.


    Cindy Meister, VSTO/Word MVP, my blog

    Tuesday, November 6, 2012 4:50 PM
    Moderator
  • Hi Matri

    Historically, using the Background parameter of the PrintOut method is not reliable. Generally, we've found it preferable to set the application-wide option, then reset it afterwards, if the user had it otherwise:

       wdApp.Options.PrintBackground = false;


    Cindy Meister, VSTO/Word MVP, my blog

    Wednesday, November 7, 2012 4:32 PM
    Moderator

All replies

  • Hi Matri

    Which version of Word are you targeting and should this solution work with newer versions, as well (Office 2013)?


    Cindy Meister, VSTO/Word MVP, my blog

    Tuesday, November 6, 2012 8:34 AM
    Moderator
  • Hi Cindy,

    We are targeting 2003, 2007, 2010 as of now.

    Regards,
    Matri

    Tuesday, November 6, 2012 3:23 PM
  • Hi Matri

    For Word 2007 and Word 2010 you'd have the option of re-purposing the FilePrint (and FilePrintPreview) commands via a Ribbon XML customization that's part of your Add-in.

    In the <commands> section of the Ribbon XML you'd need a <command> element for each command you want to re-purpose, with the idMso set to that of the command in question. In this case you would not also use DocumentBeforePrint.

    In the callback code for the command simply cancel the default, perform the steps you want to execute prior to the command itself being called, then send the PrintOut command for the document, and afterwards comes the code you want to execute after printing has taken place. Note that it will be necessary for you to make sure Background Printing is disabled.

    For Word 2003, this approach is not possible except using VBA, where you'd create a macro named FilePrint (and one for FilePrintPreview).

    In 2013 there is no equivalent option available due to printing have been incorporated into Backstage. For 2013 you'd need to create your own Print tab in order to take control of printing.


    Cindy Meister, VSTO/Word MVP, my blog

    Tuesday, November 6, 2012 4:50 PM
    Moderator
  • Thanks,

    on one url it is said that as below -

    ---------------------

    Set the Background parameter of the PrintOut method to False, so that the next line of code doesn't execute until the print file has been spooled to the printer queue.

    ActiveDocument.Printout Background:=False
    -----------------------------------

    Could you please let me know what is the corresponding code in c# for settingup this background.

    Thanks,

    Matri

    Tuesday, November 6, 2012 5:21 PM
  • Hi Matri

    Historically, using the Background parameter of the PrintOut method is not reliable. Generally, we've found it preferable to set the application-wide option, then reset it afterwards, if the user had it otherwise:

       wdApp.Options.PrintBackground = false;


    Cindy Meister, VSTO/Word MVP, my blog

    Wednesday, November 7, 2012 4:32 PM
    Moderator