Shell Command Not working When Printing PDF

concreteinterface

Board Regular
Joined
Jul 10, 2008
Messages
144
Ok, so I had this working a while ago, but I've since updated Adobe and it doesn't seem to be working now. It executes the code correctly and opens Adobe Reader, but the printer never prints anything. Here is the shell command I am sending:

Code:
C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe /n /h /t "\\10.20.59.47\Shared\MISWO\Work Order Programming\PDF\New NVR Server Installation Checklist.pdf" \\miller-dc1\TOSHIBA-FRONT-OFFICE

...and here is the full code. Some of this will probably not make sense.

Code:
Private Sub CommandButton1_Click()

Dim PageCount As Integer
Dim AddPageCount As Integer
Dim i As Integer
Dim CBox As String
Dim DocToPrint As String
Dim PD As String
 
PageCount = 0
My_filenumber = FreeFile
logSTR = ""
PD = "\\10.20.59.47\Shared\MISWO\Work Order Programming\Printed Documents.csv"


For i = 2 To 81
    CBox = "CheckBox" & i - 1
        With Me.Controls(CBox)
            If .Value = True Then
                AddPageCount = Sheets("Documents").Range("BC" & i).Value
                PageCount = PageCount + AddPageCount
            End If
        End With
        
Next


If PageCount > 10 Then AYS = MsgBox("You are about to print " & PageCount & " pages.  Are you sure?", vbYesNo)
If AYS = vbNo Then Exit Sub


PDFExe = "C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe"


For i = 2 To 81
    CBox = "CheckBox" & i - 1
        With Me.Controls(CBox)
            If .Value = True Then
                DocToPrint = "\\10.20.59.47\Shared\MISWO\Work Order Programming\PDF\" & Sheets("Documents").Range("D" & i).Value
                zCommand = PDFExe & " /n /h /t " & Chr(34) & DocToPrint & Chr(34) & " \\miller-dc1\TOSHIBA-FRONT-OFFICE"
                
    With New MSForms.DataObject
        .SetText zCommand
        .PutInClipboard
    End With
    
                Shell (zCommand)
                Application.Wait (Now + TimeValue("00:00:01"))
                logSTR = Format(Date, "yyyy-mm-dd") & "," & Format(Time, "hh:mm:ss") & "," & DocToPrint & "," & UserName
                Open PD For Append As #My_filenumber
                    Print #My_filenumber, logSTR
                Close #My_filenumber
            End If
        End With
        
Next


Unload Me


End Sub

I'm not so sure that shell command is correct as I don;t really know what I'm looking at. I've just copied from a website and made it work. Any help would be much appreciated. Thanks!
 

Excel Facts

Remove leading & trailing spaces
Save as CSV to remove all leading and trailing spaces. It is faster than using TRIM().
If you are using Windows, you can open a shell window and type in the shell command to see if it works there. To open a shell window, in Run, enter cmd.exe. A black window will appear. That's the shell window, a.k.a command window.
 
Upvote 0

Forum statistics

Threads
1,216,120
Messages
6,128,948
Members
449,480
Latest member
yesitisasport

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