none
Excel WorkbookBeforePrint event does not fire for PrintPreview RRS feed

  • Question

  • Our team has developed a custom ribbon for Excel using VB in VS 2010 where we want to apply some formatting before printing a workbook. We don't want to perform the formatting unless the user is going to print the workbook because of performance issues (we don't want the user waiting an extra few seconds for something that won't be used.

    The Application.WorkbookBeforePrint event handler works quite well for setting up the printing, but we would like to intercept the PrintPreview dialog to perform the formatting prior to PrintPreview so that the user gets to preview the actual formatted output.

    There seem to be workarounds that repurpose the PrintPreview button, but these depend on building an XML file and embedding it as a resource. We would prefer to avoid this solution.

    Does anybody know of a way to intercept the PrintPreview dialog before it shows?


    David M. Nichols software engineer

    Thursday, March 5, 2015 6:03 PM

Answers

  • Hello David,

    The Excel object model (nor VSTO) doesn't provide anything for that.

    Try to repurpose the ribbon controls. See Temporarily Repurpose Commands on the Office Fluent Ribbon for more information.

    P.S. Ask Excel specific questions on the Excel for Developers forum instead. The current forum is for VSTO related questions.

    Thursday, March 5, 2015 7:19 PM
  • Hi David M. Nichols,

    >>Excel WorkbookBeforePrint event does not fire for PrintPreview <<

    Based on my understanding, it is expected. Since this event only fire before printing the workbook and you can get more detail about this event from link below:
    Workbook.BeforePrint Event

    >>Does anybody know of a way to intercept the PrintPreview dialog before it shows?<<

    As Eugene metioned, there is no such API in Excel object model to handle this secnario. If you don't want to repurpose the comands on the ribbon, I suggest that you submit the feedback from link below:
    Submit Feedback - Microsoft Support

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, March 6, 2015 7:24 AM
    Moderator

All replies

  • Hello David,

    The Excel object model (nor VSTO) doesn't provide anything for that.

    Try to repurpose the ribbon controls. See Temporarily Repurpose Commands on the Office Fluent Ribbon for more information.

    P.S. Ask Excel specific questions on the Excel for Developers forum instead. The current forum is for VSTO related questions.

    Thursday, March 5, 2015 7:19 PM
  • Hi David M. Nichols,

    >>Excel WorkbookBeforePrint event does not fire for PrintPreview <<

    Based on my understanding, it is expected. Since this event only fire before printing the workbook and you can get more detail about this event from link below:
    Workbook.BeforePrint Event

    >>Does anybody know of a way to intercept the PrintPreview dialog before it shows?<<

    As Eugene metioned, there is no such API in Excel object model to handle this secnario. If you don't want to repurpose the comands on the ribbon, I suggest that you submit the feedback from link below:
    Submit Feedback - Microsoft Support

    Regards & Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, March 6, 2015 7:24 AM
    Moderator