1

I have been spending a great deal of time trying to solve this issue and searched many forums but I have not yet found a solution. Maybe someone here can find an answer...

I want to run some code (change some cells to shift conditional formatting, hide some rows etc.) before user prints the workbook.

In the old days this was simply accomplished by running the in-built _BeforePrint event in excel:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
    'Do something
End Sub

In excel 2010 and up the user are able to click print-preview after either hitting Ctrl-P or go to File->Print.

The _BeforePrint event only fires after the user actually clicks Print!

Therefore the user are seeing a print preview of the sheet before my macro has been running. The sheet now do not look good for printing and the user starts to manipulate the sheet because they do not know the sheet will be arranged for printing after they press the Print button.

Anyone got a solution to this?

4
  • This is not a solution, but seems to be a good workaround blog.contextures.com/archives/2011/09/28/…
    – jcbermu
    Aug 4, 2015 at 12:05
  • Where did you put this code? thisworkbook module? Aug 4, 2015 at 12:23
  • @Raystafarian Yes, it has to be in thisworkbook module, else it will not run on the print event.
    – stine
    Aug 4, 2015 at 14:17
  • @jcbermu Thanks, unfortunately this does not solve my problem as the users will still be able to go to File->Print as they are used to and see the wrong/bad format.
    – stine
    Aug 4, 2015 at 14:19

0

You must log in to answer this question.