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
 

Some videos you may like

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.

Sektor

Well-known Member
Joined
May 6, 2011
Messages
2,834
Swap the lines with printers to see whether second printer is found.
 

Bub_the_Zombie

Board Regular
Joined
Nov 1, 2016
Messages
53
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
 

Watch MrExcel Video

Forum statistics

Threads
1,123,240
Messages
5,600,490
Members
414,383
Latest member
konmtu

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
Top