Quantcast
Channel: PDFCreator - pdfforge forums
Viewing all articles
Browse latest Browse all 2622

Print a Internet Explorer in PDF using VBA

$
0
0

@Leandro_Rezende wrote:

Hi, I am trying print a Internet Explorer page in PDF using VBA code, but I am having problem with “ActiveDocument.PrintOut”. I tried “ExecWB” and used some part from example code of the own PDFcreator, but in this point I have error. I would like that PDfcreator print automatically to a path, without open the dialog box of PDFcreator.
Follow I have my Code:
Sub ImprimirInternetComPDFCreator()

Dim Explorer As Object
Dim fullPath
Dim PDFCreatorQueue As Variant
Dim printJob As Variant

Set PDFCreatorQueue = CreateObject(“PDFCreator.JobQueue”)
fullPath = “linktogoogle”

'Connect to Internet Explorer
Set Explorer = CreateObject(“InternetExplorer.Application”)
'Open some document. This is usually a file on your computer, but I use Google here for test purposes
Explorer.Navigate "googlelinkforexample"
Explorer.Visible = True

'Set printer if necessary
SetDefaultPrinter (“PDFCreator”)

TryAgain:
'Wait for 2 seconds to let IE load the document
fTime = Timer
Do While fTime > Timer - 2
DoEvents
Loop
eQuery = Explorer.QueryStatusWB(6) 'get print command status
If eQuery And 2 Then

ActiveDocument.PrintOut

        'Wait for 2 seconds while IE prints
        fTime = Timer
        Do While fTime > Timer - 2
            DoEvents
        Loop
    Else
        GoTo TryAgain
    End If

MsgBox "Waiting for the job to arrive at the queue…"
If Not PDFCreatorQueue.WaitForJob(100) Then
MsgBox "The print job did not reach the queue within " & " 10 seconds"
Else
Set printJob = PDFCreatorQueue.NextJob

printJob.SetProfileByGuid ("DefaultGuid")

MsgBox "Converting under ""DefaultGuid"" conversion profile"
printJob.ConvertTo (fullPath)

If (Not printJob.IsFinished Or Not printJob.IsSuccessful) Then
    MsgBox "Could not convert the file: " & fullPath
Else
    MsgBox "Job finished successfully"
End If

End If

MsgBox "Releasing the object"
PDFCreatorQueue.ReleaseCom
End Sub

Somebody could help me?

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 2622

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>