If I run the code in debug mode (line by line execution) I am not getting any problem, But if I run without debug mode Adobe Acrobat opens with the specified file and says "Could not print the job"
I have given the code
Public Function PrintPDF(afileName As String) As String
'definitions
Dim strFileName As String
On Error GoTo errhnd
Dim acroApp As CAcroApp
Dim pdDoc As CAcroPDDoc
Dim avDoc As CAcroAVDoc
Dim pdTextSelect As CAcroPDTextSelect
Dim acroRect As CAcroRect
Dim intPage As Integer
Dim bFileOpen As Boolean
Dim bSelectSet As Boolean
Dim bShowSelect As Boolean
Dim a As String
Dim pdpage
On Error GoTo errhnd
'Creating the objects
Print #100, "PrintPDF routine"
Print #100, "Creating Object ACroExch.app"
Set acroApp = CreateObject("AcroExch.App", "")
Print #100, "Object ACroExch.app created successfully"
Print #100, "Creating Object AcroExch.PDDoc"
Set pdDoc = CreateObject("AcroExch.PDDoc", "")
Print #100, "Object ACroExch.PDDoc created successfully"
Print #100, "Creating Object AcroExch.AVDoc"
Set avDoc = CreateObject("AcroExch.AVDoc", "")
Print #100, "Object ACroExch.PDDoc created successfully"
Print #100, "Creating Object AcroExch.Rect"
Set acroRect = CreateObject("AcroExch.Rect", "")
Print #100, "Object AcroExch.Rect created successfully"
'Setting the booleans
bFileOpen = False
bSelectSet = False
bShowSelect = False
'Show the Application
acroApp.Show
'Open the test document
strFileName = "" + afileName + ""
bFileOpen = avDoc.Open(strFileName, "")
'if the test file opened
Print #100, "Opening File " & strFileName
If (bFileOpen) Then
'Get the PDDoc
Set pdDoc = avDoc.GetPDDoc
'Set to the first page
intPage = 0
intPage = pdDoc.GetNumPages
Print #100, "Number of Pages in PDF file " & afileName & " is " & intPage
a = avDoc.PrintPagesSilent(0, intPage - 1, 2, True, True)
If a Then
Print #100, "File " & afileName & " printed Successfully"
End If
'close the document
avDoc.Close (False)
acroApp.Exit
End If
'clean up
Set pdTextSelect = Nothing
Set acroRect = Nothing
Set pdpage = Nothing
Set pdDoc = Nothing
Set avDoc = Nothing
Set acroApp = Nothing
PrintPDF = strlog
errhnd:
Print #100, "*******************************ERROR*******************************"
Print #100, "PrintPDF"
Print #100, Err.Description
End Function
Reinhard Franke "Seperateing a file for print" 10/27/02 10:24am </cgi-bin/webx?14@@.1de65451/5>
It's a solution via JSObject that works.
HTH, Reinhard