VBA Print by PDFCreator
-
I'm trying to print an IE file by the PDFCreator, in my surveys I couldn't locate a form in VBA to perform this process, until I found an algorithm that says do this, so I couldn't solve a problem with WshNetwork, it gives me how build error, as type not defined by the user. I wonder if someone knows a way to work with the PDFCreator for vba, make them print a page, using the program, in full, that is, where I can determine the file name and put the path, if it is not possible, something that gives me a point or something.
-
I managed to find the answer in another forum, to which I do not remember now and unfortunately I cannot give credit to the author.
It follows the way I managed to perform the whole 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
Looppdfjob.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