Basic VBA Question
Still not working...
I get the following message:
Run-time error '1004':
Method 'ActivePrinter' of object' _Application' failed
and when I hit debug, this whole line is yellow:
Application.ActivePrinter = "//IDB-NY509-04-TRADER-4600C"
Thanks again, Amir.
Tom Ogilvy wrote:
Sub PrintBlotter()
'
' PrintBlotter Macro
' Macro recorded 12/18/2006 by Reuters LTD
'
' capture current default
s = Application.ActivePrinter
' set it to the desired printer
Application.ActivePrinter = _
"//IDB-NY509-04-TRADER-4600C"
' Print out
ActiveSheet.PrintOut From:=1, To:=1, Copies:=1, Collate:=True
' Restore the default
Application.ActivePrinter = s
End Sub
Would be my best guess based on what you show.
--
Regards,
Tom Ogilvy
"amirstal" wrote:
Thanks.
I could not get it to work.
This is how I tried:
Sub PrintBlotter()
'
' PrintBlotter Macro
' Macro recorded 12/18/2006 by Reuters LTD
'
Print Application.ActivePrinter
//IDB-NY509-04-TRADER-4600C
ActiveSheet.PrintOut From:=1, To:=1, Copies:=1, Collate:=True
'
End Sub
But I got the following message:
Compile error:
Method not valid without suitable object.
Thanks,
Amir
Tom Ogilvy wrote:
Select the printer you want.
then in the immediate window to
? application.ActivePrinter
for example:
? application.ActivePrinter
\\ARDAPS01\1D373C on Ne03:
Now use this string to set the activeprinter (of course capture the default
and set it back after printing).
--
Regards,
Tom Ogilvy
"amirstal" wrote:
Thanks. That works perfectly.
Can I also make the code choose a specific printer to print from? I
want to direct the prints to a different printer than the default...
Tom Ogilvy wrote:
Activesheet.PrintOut From:=1, To:=1, _
Copies:=1, Collate:=True
Range("A1:B5").Printout
or selection.Printout
--
Regards,
Tom Ogilvy
"amirstal" wrote:
What is the code I need to write in order to:
1. Print the first page of an active worksheet?
2. Print a selected range (A1:B5 for example) of an active worksheet?
Thanks.
|