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:
...and here is the full code. Some of this will probably not make sense.
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!
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!