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?
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.

Forum statistics

Threads
1,215,024
Messages
6,122,729
Members
449,093
Latest member
Mnur

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