PDA

View Full Version : Why cannot print PDF



clif
08-29-2023, 10:11 PM
Could anyone help to see why i cannot printout! Thanks!

Call AcroAVDoc.PrintPages(0, pageNo, 2, 1, 1) is not working!





Sub Checkfigures()


Application.ScreenUpdating = False




Dim searchString As String
Dim blnSearch As Boolean
Dim AcroApp As Acrobat.CAcroApp
Dim AcrobatDoc As Acrobat.CAcroPDDoc
Dim AcroAVDoc As Object
Dim pageNo As Integer
Dim ws As Worksheet
Set ws = ThisWorkbook.Worksheets("Sheet2")
Dim a As Integer

Set AcroApp = Nothing
Set AcrobatDoc = Nothing
Set AcroAVDoc = Nothing


Set AcroApp = CreateObject("AcroExch.App")
Set AcrobatDoc = CreateObject("AcroExch.PDDoc")

AcroApp.Show
AcrobatDoc.Open (ws.Cells(1, 1).Value)


Set AcroAVDoc = AcrobatDoc.OpenAVDoc("")

For a = 2 To 6

searchString = ws.Cells(a, 4).Value

blnSearch = AcroAVDoc.FindText(szText:=searchString, _
bCaseSensitive:=False, _
bWholeWordsOnly:=True, _
bReset:=2)

Set pdDoc = AcroAVDoc.GetPDDoc()
Set jso = pdDoc.GetJSObject
pageNo = jso.pageNum



Call AcroAVDoc.PrintPages(0, pageNo, 2, 1, 1)

Next a

AcrobatDoc.Close
AcroApp.CloseAllDocs
AcroApp.Exit



Application.ScreenUpdating = False


End Sub

Aussiebear
08-30-2023, 01:15 AM
Hello Clif, you suggested that Call AcroAVDoc.PrintPages(0, pageNo, 2,1,1) is not working but supplied the code for the Sub CheckFigures module. Within that module you call the sub routine AcroAVDoc.PrintPages(0,2,1,1). Which sub routine is causing the issue?

jdelano
09-01-2023, 03:04 AM
From what I can see this line
Call AcroAVDoc.PrintPages(0, pageNo, 2, 1, 1) should be
AcroAVDoc.PrintPages(0, pageNo, 2, 1, 1) you don't need to use Call there as that is for transferring control to subprocedures and not methods of objects.

clif
09-05-2023, 08:24 PM
From what I can see this line
Call AcroAVDoc.PrintPages(0, pageNo, 2, 1, 1) should be
AcroAVDoc.PrintPages(0, pageNo, 2, 1, 1) you don't need to use Call there as that is for transferring control to subprocedures and not methods of objects.

It show error, how to solve it

Aussiebear
09-05-2023, 11:30 PM
I'm guessing that when you set this
.Set AcroAVDoc = AcrobatDoc.OpenAVDoc("")
. Does it hold a value?