Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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/



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 114
Default 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!
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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!



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro & Print Preview? Ken Excel Discussion (Misc queries) 2 April 2nd 08 12:52 PM
Auto running a macro on closing Jimmy D Excel Discussion (Misc queries) 6 November 22nd 07 01:58 AM
Print Preview Macro Emanuel Violante Excel Discussion (Misc queries) 1 June 2nd 06 11:28 AM
Closing the Userform when macro is running SuperJas Excel Programming 5 December 10th 03 05:31 AM
Resuming code after closing a print preview DarrenW Excel Programming 1 July 21st 03 02:54 PM


All times are GMT +1. The time now is 10:45 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"