Print() ExecuteExcel4Macro

djt76010

Board Regular
Joined
Feb 23, 2007
Messages
109
I have previously setup code to print to a network printer for anyone who accesses that spreadsheet. I am not great at Visual Basic, but had pieced together the following code through various sources on the internet.

Code:
Sub Summary_print_all()
'
'
    Dim q As Long, sPrinterName As String
    
    On Error Resume Next
       For q = 0 To 99
          sPrinterName = "\\pbivanfp01\Xerox Versant 80 PS on Ne" & Format(q, "00") & ":"
          Application.ActivePrinter = sPrinterName
          If Err.Number = 0 Then
             q = 99
          Else
             Err.Clear
          End If
       Next q
       
    On Error GoTo 0

    complete = Worksheets("Retrieval").Range("F1")

    For Count = 1 To complete

      'OTHER MACROS TO PREPARE FOR PRINTING

      Application.ActivePrinter = sPrinterName
      ExecuteExcel4Macro "PRINT(1,,,1,,,,,,,,2,sPrinterName,,TRUE,,FALSE)"
    Next Count
End Sub

I had this code working previously, but we have changed servers and when I updated the network printer name to reflect the new server I am getting an apparently valid printer name (the For q = 0 To 99 loop does not go through to 99) but the ExecuteExcel4Macro "PRINT(1,,,1,,,,,,,,2,sPrinterName,,TRUE,,FALSE)" line is not doing anything. Any ideas of what my problem is?
 

Some videos you may like

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

Watch MrExcel Video

Forum statistics

Threads
1,127,972
Messages
5,627,933
Members
416,282
Latest member
fchagas97

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