VBA Help - Running a macro when closing print preview

  • Thread starter Thread starter carljonesuk
  • Start date Start date
C

carljonesuk

I was wandering is it possible to run a macro when i close print previe
in Excel?

If so how do i Do it ?

Any Comments would be useful!

Thanks
Car Jone
 
No really - there is not afterprint event. You could intercept the print
request in the BeforePrint event, then cancel it and manage the
printing/print preview with your code - then you could perform an action
after it was completed. However, there isn't an easy way to determine if
the request is to print or printpreview. Another approach might be to
remove all the menu choices and shortcut keys to print/print preview and
provide your own interface - but the ability to do print/print preview is
embedded in several builtin dialogs.
 
Hi Car Jones,

Try this,

Put below code into thisworkbook's codemodule.


Private Sub Workbook_BeforePrint(Cancel As Boolean)

Application.EnableEvents = False

Cancel = True

ActiveWindow.SelectedSheets.PrintPreview

Application.EnableEvents = True

'write\call you macro here
MsgBox "macro runs after print preview"

End Sub

Regards,
Shah Shailesh
http://members.lycos.co.uk/shahweb/
 
Back
Top