Accessing a PDF file through VBA

New Here ,
Jul 20, 2017

Copy link to clipboard

Copied

0down votefavorite

I was reading from a forum thread: https://forums.adobe.com/thread/604177 and started experimenting with it.
But I think the function didn't load at all. I wasn't sure what might the reason be behind it -
I reckon it has to be simple and probably related to the library.
Can someone help point out why the following code failed to compile at all?
(the code appeared not to have ran upon execution in immediate as none of the breakpoints triggered)

The libraries I have loaded include

  • Acrobat Distiller
  • Adobe Acrobat 10.0 Type Library
  • Acrobat Scan 1.0 Type Library

The computer which this code is executed on have Acrobat Professional installed on it.

Public Function GetPDF() '(FilePath As String) As Object 
Dim origPdf As Acrobat.AcroPDDoc
Dim path1 As String
MsgBox
("Start") 

path1
= Application.ActiveWorkbook.Path
path1
= path1 & "/31700100" 

Set
origPdf = CreateObject("AcroExch.PDDoc") 

If
origPdf.Open(path1) Then
MsgBox
("weee")
End If 

origPdf
.Close
Set origPdf = Nothing
End Function
Adobe Community Professional
Correct answer by Karl Heinz Kremer | Adobe Community Professional

You need a few more lines. Take a look here for a working example: Adobe Acrobat and VBA - An Introduction - KHKonsulting LLC

Add these lines to the beginning of your program and see if that fixes it:

Dim AcroApp As Acrobat.CAcroApp

Set AcroApp = CreateObject("AcroExch.App")

And, all you need is a reference to the Adobe Acrobat 10.0 Type Library

TOPICS
Acrobat SDK and JavaScript

Views

58.5K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Accessing a PDF file through VBA

New Here ,
Jul 20, 2017

Copy link to clipboard

Copied

0down votefavorite

I was reading from a forum thread: https://forums.adobe.com/thread/604177 and started experimenting with it.
But I think the function didn't load at all. I wasn't sure what might the reason be behind it -
I reckon it has to be simple and probably related to the library.
Can someone help point out why the following code failed to compile at all?
(the code appeared not to have ran upon execution in immediate as none of the breakpoints triggered)

The libraries I have loaded include

  • Acrobat Distiller
  • Adobe Acrobat 10.0 Type Library
  • Acrobat Scan 1.0 Type Library

The computer which this code is executed on have Acrobat Professional installed on it.

Public Function GetPDF() '(FilePath As String) As Object 
Dim origPdf As Acrobat.AcroPDDoc
Dim path1 As String
MsgBox
("Start") 

path1
= Application.ActiveWorkbook.Path
path1
= path1 & "/31700100" 

Set
origPdf = CreateObject("AcroExch.PDDoc") 

If
origPdf.Open(path1) Then
MsgBox
("weee")
End If 

origPdf
.Close
Set origPdf = Nothing
End Function
Adobe Community Professional
Correct answer by Karl Heinz Kremer | Adobe Community Professional

You need a few more lines. Take a look here for a working example: Adobe Acrobat and VBA - An Introduction - KHKonsulting LLC

Add these lines to the beginning of your program and see if that fixes it:

Dim AcroApp As Acrobat.CAcroApp

Set AcroApp = CreateObject("AcroExch.App")

And, all you need is a reference to the Adobe Acrobat 10.0 Type Library

TOPICS
Acrobat SDK and JavaScript

Views

58.5K

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Jul 20, 2017 0
Adobe Community Professional ,
Jul 20, 2017

Copy link to clipboard

Copied

You need a few more lines. Take a look here for a working example: Adobe Acrobat and VBA - An Introduction - KHKonsulting LLC

Add these lines to the beginning of your program and see if that fixes it:

Dim AcroApp As Acrobat.CAcroApp

Set AcroApp = CreateObject("AcroExch.App")

And, all you need is a reference to the Adobe Acrobat 10.0 Type Library

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 20, 2017 0
New Here ,
Jul 20, 2017

Copy link to clipboard

Copied

Ah! Thanks Karl. That is helpful. I got it to open just fine with the following.

My second question is then - what kind of object is the PDDoc considered as? Is it like a pointer or is it an actual object that contains all the data within the file? If I pass it as an object around, are there limitations on shallow passes and deep passes? (Say, I want to get the function to return a AcroPDDoc object and do other things with it).

Thanks!

Public Function GetPDF (FilePath As String) As Object

    Dim ArcoApp As New Acrobat.AcroApp

    Dim OriPdf As New Acrobat.AcroPDDoc

    Set ArcoApp = CreateObject("AcroExch.App")

    Set OriPdf = CreateObject("AcroExch.PDDoc")

 

    If OriPdf.Open(FilePath) Then

        MsgBox ("weee")

    End If

 

    GetPDF = OriPdf

    OriPdf.Close

    AcroApp.Close

    Set OriPdf = Nothing

    Set AcroApp =  Nothing

End Function

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 20, 2017 0
lrosenth LATEST
Adobe Employee ,
Jul 21, 2017

Copy link to clipboard

Copied

Also, make sure you download the SDK and read the documentation. Snippets on the web are not documentation…

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Jul 21, 2017 0