Hi Experts,
I'm looking for a way to send a document to docusign print driver. the code below when it works launches docusign print driver with the document in the print queue. The code below works inconsistently. sometimes it works, sometimes it doesn't work. if i step thru the code it works every time. I've adjusted the pause, trying different time interval but outcome is still inconsistent. I need a better way to do this. if anyone has experience doing this i would really appreciate some help.
I'm looking for a way to send a document to docusign print driver. the code below when it works launches docusign print driver with the document in the print queue. The code below works inconsistently. sometimes it works, sometimes it doesn't work. if i step thru the code it works every time. I've adjusted the pause, trying different time interval but outcome is still inconsistent. I need a better way to do this. if anyone has experience doing this i would really appreciate some help.
Code:
Private Sub DocuSign(strPathFile)
Dim dfltPrinter As String
Dim newPrinter As New WshNetwork
'Get the name of the default printer
dfltPrinter = Me.Printer.DeviceName
'Set the default to the new printer
'USE YOUR ACTUAL PRINTER NAME BELOW
newPrinter.SetDefaultPrinter ("Print to DocuSign")
'Pause
Sleep 2000
'Print the pdf document
'USE YOUR ACTUAL DOCUMENT NAME & PATH BELOW
Call ShellExecute(Me.hwnd, "print", strPathFile, "", 0, SW_SHOWNORMAL)
'Pause
Sleep 2000 'wait for 2 seconds - increase this if the code doesn't appear to work
'kill the acrobat process, if it is still running
KillProcess ("acrobat")
'Pause
Sleep 2000
'Set the printer back to the original default
newPrinter.SetDefaultPrinter (dfltPrinter)
End Sub