Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default ThisWorkbook BeforePrint

Hi,

I need to run code after a print job.
I am using
Private Sub Workbook_BeforePrint(Cancel As Boolean)
in ThisWorkbook to execute code prior to printing,
but then I want to run code after printing.

Thanks
Simon
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 692
Default ThisWorkbook BeforePrint

You might look into canceling the print at the beginning of the event.
Than have the code initiate the print (in the code).
Than continue your code to what you want to happen after the print.

--
steveB

Remove "AYN" from email to respond
"Simon Shaw" <simonATsimonstoolsDOTcom wrote in message
...
Hi,

I need to run code after a print job.
I am using
Private Sub Workbook_BeforePrint(Cancel As Boolean)
in ThisWorkbook to execute code prior to printing,
but then I want to run code after printing.

Thanks
Simon



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default ThisWorkbook BeforePrint

Make sure that if you do this, you disable events prior to printing and
reenable them afterward, or you'll loop until you run out of stack
space. For instance:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Cancel = True
Application.EnableEvents = False
ActiveSheet.PrintOut
Application.EnableEvents = True
'Your code here
End Sub



In article ,
"Simon Shaw" <simonATsimonstoolsDOTcom wrote:

Hi,

I need to run code after a print job.
I am using
Private Sub Workbook_BeforePrint(Cancel As Boolean)
in ThisWorkbook to execute code prior to printing,
but then I want to run code after printing.

Thanks
Simon

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default ThisWorkbook BeforePrint

what if the user was performing a print preview... how do I tell the
difference?

"JE McGimpsey" wrote:

Make sure that if you do this, you disable events prior to printing and
reenable them afterward, or you'll loop until you run out of stack
space. For instance:

Private Sub Workbook_BeforePrint(Cancel As Boolean)
Cancel = True
Application.EnableEvents = False
ActiveSheet.PrintOut
Application.EnableEvents = True
'Your code here
End Sub



In article ,
"Simon Shaw" <simonATsimonstoolsDOTcom wrote:

Hi,

I need to run code after a print job.
I am using
Private Sub Workbook_BeforePrint(Cancel As Boolean)
in ThisWorkbook to execute code prior to printing,
but then I want to run code after printing.

Thanks
Simon


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default ThisWorkbook BeforePrint

AFAIK, there's no way to detect the difference between Print and Print
Preview.

However, you can trap the Print Preview command with something like:

CommandBars(1).Controls("File").Controls("Print Preview").OnAction:= _
"MyMacro"

and

Commandbars("Standard").FindControl(id:=109).OnAct ion = "MyMacro"

In article ,
"Simon Shaw" <simonATsimonstoolsDOTcom wrote:

what if the user was performing a print preview... how do I tell the
difference?

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
BeforePrint macro Steve O Excel Discussion (Misc queries) 4 September 21st 05 01:09 AM
ADO 2.7 & ADO 2.8 beforeprint JCanyoneer Excel Programming 7 March 30th 05 04:05 PM
Update header BeforePrint JCanyoneer Excel Programming 2 March 22nd 05 05:45 PM
BeforePrint event EnglishTeacher Excel Programming 4 October 13th 04 04:17 PM
Help with BeforePrint Eric[_7_] Excel Programming 2 October 9th 03 07:44 PM


All times are GMT +1. The time now is 09:08 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"