I was able to find the answer in another forum, which I can’t remember now and unfortunately I can’t give credit to the author.
It follows the way I was able to perform the entire procedure in the background.
'- atribui nome do documento e o caminho para download as devidas variaveis
sPDFNome = "name"
sPDFPath = "c:\teste" & contrato & Application.PathSeparator
'seta a variavel e cria o objeto do pdf creator
Set pdfjob = CreateObject("PDFCreator.clsPDFCreator")
'- verifica se o programa esta aberto - caso esteja ele vai mandar uma mensagem para e finalizar a sub
'- caso nao esteja -
With pdfjob
If .cStart("/NOProcessingAtStartup") = False Then
MsgBox "Programa Aberto", vbCritical + vbOKOnly, "prtPDFCreator"
Exit Sub
End If
.cOption("UseAutosave") = 1
.cOption("UseAutosaveDirectory") = 1
.cOption("AutosaveDirectory") = sPDFPath
.cOption("AutosaveFilename") = sPDFNome
.cOption("AutosaveFormat") = 0 '0 = pdf
.cClearCache
End With
'- enviar comando para imprimir
'ie.PrintOut copies:=1, ActivePrinter:="PDFCreator"
ie.ExecWB 6, 2, "", ""
'- verifica se o arquivo derminou de ser impresso
Do Until pdfjob.cCountOfPrintjobs = 1
DoEvents
Loop
pdfjob.cPrinterStop = False
'- verifica se tem algum arquivo na lista de impressao
Do Until pdfjob.cCountOfPrintjobs = 0
DoEvents
Loop
'- fechar a impressa
pdfjob.cClose
'- larga o objeto
Set pdfjob = Nothing
For automations with programs, windows, buttons. I use the Autoit. In which an Autoit script is created and then can be called by VBA. There are complex ways to work with non-windows software in VBA, one of them is to import libraries. dll, but I find Autoit easier for specific applications
– danieltakeshi
@danieltakeshi I managed to solve this problem the following way, but I appreciate your tip depth and I will guard for future applications. =)
– M. Marins