ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Excel printing macro problem (https://www.excelbanter.com/excel-programming/353690-excel-printing-macro-problem.html)

Cam[_6_]

Excel printing macro problem
 

Hi, I just can't get this to work - I keep getting Runtime error 1004 ?
The aim is just to print to another printer called 'HP 1200 Tray 2'

Any tips would be great. Thanks.

*Sub Printer2()

Dim STDprinter As String
STDprinter = Application.ActivePrinter
Application.ActivePrinter = "HP 1200 Tray 2 on
HPBusinessInkjet1200:"
' change printer
ActiveSheet.PrintOut
' prints the active sheet
Application.ActivePrinter = STDprinter
' change back to standard printer
End Sub*


--
Cam
------------------------------------------------------------------------
Cam's Profile: http://www.excelforum.com/member.php...o&userid=27836
View this thread: http://www.excelforum.com/showthread...hreadid=513986


keepITcool

Excel printing macro problem
 

My guess:
excel doesnt use the 32bit portname but it's 16bit sibling.
e.g. MyPrinter on Ne01:

manually set the printer to the one you want.
type ?ActivePrinter in the immediate pane.
use that string in your code.


--
keepITcool
| www.XLsupport.com | keepITcool chello nl | amsterdam


Cam wrote in


Hi, I just can't get this to work - I keep getting Runtime error 1004
? The aim is just to print to another printer called 'HP 1200 Tray 2'

Any tips would be great. Thanks.

*Sub Printer2()

Dim STDprinter As String
STDprinter = Application.ActivePrinter
Application.ActivePrinter = "HP 1200 Tray 2 on
HPBusinessInkjet1200:"
' change printer
ActiveSheet.PrintOut
' prints the active sheet
Application.ActivePrinter = STDprinter
' change back to standard printer
End Sub*


Cam[_7_]

Excel printing macro problem
 

..... your guess was spot on - you're a star.

Thanks bud.


--
Cam
------------------------------------------------------------------------
Cam's Profile: http://www.excelforum.com/member.php...o&userid=27836
View this thread: http://www.excelforum.com/showthread...hreadid=513986



All times are GMT +1. The time now is 07:32 PM.

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