Help fix my print macro

twarden

Board Regular
Joined
Jun 29, 2006
Messages
64
I'm close - but I want the 'user' to be able to enter the number zero to either of my prompts without causing the macro to fail. Currently, if a user does not want to print any color copies (i.e. enters 0 - or B&W for that matter) the macro fails. Any ideas?

Code:
Sub Print_Report()
Dim CCopies, bwcopies As Integer

Copies = Application.InputBox("How many color copies?", Type:=1)
Copies = Application.InputBox("How many B&W copies?", Type:=1)
Sheets("YTD").PrintOut Copies:=CCopies, ActivePrinter:= _
        "network_address_goes_here:", Collate:=True
Sheets("YTD Graph").PrintOut Copies:=CCopies, ActivePrinter:= _
        "network_address_goes_here", Collate:=True
Sheets("YTD").PrintOut Copies:=bwcopies, ActivePrinter:= _
        "network_address_goes_here", Collate:=True
Sheets("YTD Graph").PrintOut Copies:=bwcopies, ActivePrinter:= _
        "network_address_goes_here", Collate:=True

End Sub
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Hi Norrie - sorry to mislead you. The macro I'm using in my workbook does specify the printer address - but for simplicity's sake I've taken it out of what I've posted to the discussion board. However, the addresses are right, because as I mentioned, when I type "0" for the number of color copies, & any number for the number of B&W copies, they B&W copies print out on the B&W printer. However, whenever any number above zero is entered for the number of color copies, both B&W & Color copies print out from the color printer. So I suspect the problem is with the macro - not the printer address.........
 
Upvote 0
You may need to set the printer first then send the copies, this is how you do it. You can take the key code out and put it into your original code:


Sub PrintToOther()
Dim originalPrinter
'Print to a different printer and go back to the original printer when done.

MsgBox "The current active printer is: " & Chr(13) & Chr(13) & _
Application.ActivePrinter

originalPrinter = Application.ActivePrinter

Application.ActivePrinter = "\\print\W_2500_AL on Ne02:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"\\print\W_2500_AL on Ne02:", Collate:=True

MsgBox "The active printer for this job is now: " & Chr(13) & Chr(13) & _
Application.ActivePrinter

Application.ActivePrinter = originalPrinter

MsgBox "The current active printer is: " & Chr(13) & Chr(13) & _
Application.ActivePrinter

End Sub


The key line is:

Application.ActivePrinter = "\\print\W_2500_AL on Ne02:"
 
Upvote 0

Forum statistics

Threads
1,214,911
Messages
6,122,198
Members
449,072
Latest member
DW Draft

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top