Has anyone had any problems mass printing PDF files with acrobat using VBA? My code seems to work most of the time, but randomly it just doesn't print the file. This is for outlook, but that really shouldn't matter for this part of the code. The files get saved to the correct location according to the rule 100% of the time. Printing seems to only work like 80-90% of the time for PDF files. There isn't any error, it juts doesn't print. I added the sleep (2 seconds) and Do Until loops to try and make sure Shell is returning a valid process id, but it doesn't seem to work.
Any ideas? (Yes i know this is the excel forum, but you guys don't have an Outlook forum )
Code:
For k = Len(olAtts(j)) To 1 Step -1
If Mid(olAtts(j), k, 1) = "." And extfound = False Then
'extension determined, go with it
AttName = Left(olAtts(j), k - 1)
AttExt = Right(olAtts(j), Len(olAtts(j)) - k + 1)
extfound = True
End If
Next k
'set file name structure
AttFileSavename = AttName & "_" & Format(objMsg.SentOn, "hh.mm.ss") & AttExt
olAtts(j).SaveAsFile rtFolder & sender_folder & "\" & dStr & "\" & AttFileSavename
Select Case LCase(AttExt)
Case ".jpg", ".gif", ".png", ".bmp"
'do nothing
Case ".pdf"
If prFlag = True Then
RetVal = Null
Do Until IsNumeric(RetVal) And RetVal <> 0
Call Sleep(pDelay)
DoEvents
RetVal = Shell(AcroPath & "AcroRd32.exe /t /h " & Chr(34) & rtFolder & sender_folder & "\" & dStr & "\" & AttFileSavename & Chr(34))
'Print using acrobat reader, since for some reason we don't have the shell extension
Loop
End If
Case Else
If prFlag = True Then
RetVal = Null
Do Until RetVal = 2 Or RetVal = 31 Or RetVal > 32
Call Sleep(pDelay)
DoEvents
RetVal = ShellExecute(0, "print", rtFolder & sender_folder & "\" & dStr & "\" & AttFileSavename, "", "", 1)
'Print using shell extension
Loop
End If
End Select
Any ideas? (Yes i know this is the excel forum, but you guys don't have an Outlook forum )