ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBA Help - Running a macro when closing print preview (https://www.excelbanter.com/excel-programming/290716-vba-help-running-macro-when-closing-print-preview.html)

carljonesuk[_2_]

VBA Help - Running a macro when closing print preview
 
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

--
Message posted from http://www.ExcelForum.com


Tom Ogilvy

VBA Help - Running a macro when closing print preview
 
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.

--
Regards,
Tom Ogilvy

"carljonesuk " wrote in message
...
I was wandering is it possible to run a macro when i close print preview
in Excel?

If so how do i Do it ?

Any Comments would be useful!

Thanks
Car Jones


---
Message posted from http://www.ExcelForum.com/




Shailesh Shah[_2_]

VBA Help - Running a macro when closing print preview
 
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/


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Tom Ogilvy

VBA Help - Running a macro when closing print preview
 
So anytime anyone prints it will just do a printpreview.

--
Regards,
Tom Ogilvy

"Shailesh Shah" wrote in message
...
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/


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!





All times are GMT +1. The time now is 02:16 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com