Vba to print to 2 network printers

Bub_the_Zombie

Board Regular
Joined
Nov 1, 2016
Messages
53
Greetings Excel Gurus!

I have searched around most of the morning to try and solve this question before jumping to the boards.

I am trying to print sheet 2, to two different network printers. Can someone please help me with this code.

Code:
Private Sub CommandButton3_Click()
Application.ScreenUpdating = False
    Dim WS As Worksheet
    
    Set WS = Sheets("SHEET 2")
    Application.ActivePrinter = ("[URL="file://\\BHSDC002.BHS.LOCAL\WB-MHPHP"]\\BHSDC002.BHS.LOCAL\WB-MHPHP[/URL]")
    WS.PrintOut Copies:=1
    Application.ActivePrinter = ("[URL="file://\\BHSDC002.BHS.LOCAL\E3-PA01-HPLJ3015"]\\BHSDC002.BHS.LOCAL\E3-PA01-HPLJ3015[/URL]")
    WS.PrintOut Copies:=1
    
    Application.ScreenUpdating = True
End Sub

The error message is
Run-time error'1004':
Method"ActivePrinter" of object"_Application" failed
Then this gets highlighted in the VBA code
Code:
Application.ActivePrinter = ("[URL="file://\\BHSDC002.BHS.LOCAL\WB-MHPHP"]\\BHSDC002.BHS.LOCAL\WB-MHPHP[/URL]

Thankful for any help
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Swap the lines with printers to see whether second printer is found.
 
Upvote 0
I tried switching around the code and still got the error message.

Note that I only put one printer in the code as to not spam another department while I experiment.

Code:
Private Sub CommandButton3_Click()
Application.ScreenUpdating = False
    Dim WS As Worksheet
    Set WS = Sheets("SHEET 2")
    
    WS.PrintOut Copies:=1
    Application.ActivePrinter = ("[URL="file://bhsdc002.bhs.local/WB-MHPHP"]\\BHSDC002.BHS.LOCAL\WB-MHPHP[/URL]")
    
    Application.ScreenUpdating = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,894
Messages
6,122,124
Members
449,066
Latest member
Andyg666

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