Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

calling BeforePrint from any workbook

Status
Not open for further replies.

PeggyC

Programmer
Apr 4, 2002
15
US
Hello,

I'm using Excel 2003. I've created a personal.xls file to run every time Excel is opened. In personal.xls I have a macro that I want to run whenever someone hits the Print button in any workbook. I'm trying to change the printer that Excel will print to (but not the default printer of the computer).

This is in ThisWorkbook of personal.xls :
Sub Workbook_BeforePrint(Cancel As Boolean)
MsgBox "This is working!!" 'test to see if this runs
Application.activeprinter = "bsmt on Ne00:"
End Sub

The macro works but when I go to File-print in any other excel workbook it doesn't work. How do I get this to work for any Workbook that I open and not just personal.xls?

Thanks,
Peggy

 


Hi,

The BeforePrint Event is for the workbook frim which the print command is issued.

Why don't you put your code in the PERSONAL.xls WorkbookOpen event?

Skip,
[sub]
[glasses] [red]Be Advised![/red] For those this winter, caught in Arctic-like calamity, be consoled...
Many are cold, but few are frozen![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top