Hello All,
I am very new to PDF X-Change Editor. I have downloaded the PDF X-Change Editor Type Library and the PDF X-Change PDF Core Library. I am trying to write VBA to read the values of fields in PDF X-Change Editor form and then I'll write those values to Excel. I have added the references in Excel to these libraries. I am confused on how to open the document and get it as a PDFXEdit.IPXC_Document object. Below is my snippet. It fails on the opendocfrompath method. Any help is very much appreciated.
Thank you!
Thayana
Option Explicit
Private mobjPDFCtl As PDFXEdit.PXV_Control
Private mobjPDFInst As PDFXEdit.PXV_Inst
Private mobjPDFDoc As PDFXEdit.IPXC_Document
Private mobjFormField As PDFXEdit.IPXC_FormField
Private mstrText As String
Private Const strPath As String = "2019 Smith, Joan.pdf"
Private strRelPath As String
Sub Init()
Set mobjPDFCtl = New PDFXEdit.PXV_Control
Set mobjPDFInst = mobjPDFCtl.Inst
strRelPath = ThisWorkbook.Path & "\" & strPath
Set mbojPDFDoc = mobjPDFCtl.OpenDocFromPath(strRelPath)
Set mobjFormField = mobjPDFDoc.AcroForm.GetFieldByName("Text1")
mstrText = mobjFormField.GetValueText
End Sub
Read Field Values into Excel
Moderators: TrackerSupp-Daniel, Tracker Support, Paul - Tracker Supp, Vasyl-Tracker Dev Team, Chris - Tracker Supp, Sean - Tracker, Ivan - Tracker Software, Tracker Supp-Stefan
Forum rules
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.
When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
DO NOT post your license/serial key, or your activation code - these forums, and all posts within, are public and we will be forced to immediately deactivate your license.
When experiencing some errors, use the IAUX_Inst::FormatHRESULT method to see their description and include it in your post along with the error code.
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Read Field Values into Excel
Hi Thayana,
I think you only will have to open the IPXC_Document vial the Core API level, without the usage of the Editor Level SDK. You can check out the CoreAPIDemo application that comes in the Samples package along with the Core API SDK - it holds practical usage samples that are frequently being updated.
Cheers,
Alex
I think you only will have to open the IPXC_Document vial the Core API level, without the usage of the Editor Level SDK. You can check out the CoreAPIDemo application that comes in the Samples package along with the Core API SDK - it holds practical usage samples that are frequently being updated.
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 4
- Joined: Fri Feb 21, 2020 5:02 pm
Re: Read Field Values into Excel
Hello Alex,
I tried doing this by looking at the C# code for opening a document and then converting to vb in my Excel document. I have the reference set to the PDF-Xchange PDF Core API Library. I am still getting an error on the line to open the file that an object is needed. I am not sure what I am going wrong. Below is my code. Any help is much appreciated. I am not sure what else to try at this point, but it certainly seems that I should be able to open a document and read a field from the AcroForm according to the documentation.
Thank you!
Thayana
Option Explicit
Private mstrText As String
Private Const strPath As String = "2019 Smith, Joan.pdf"
Private strRelPath As String
Private mobjPDFInst As PDFXCoreAPI.PXC_Inst
Private mobjPDFDoc As PDFXCoreAPI.IPXC_Document
Private mobjFormField As PDFXCoreAPI.IPXC_FormField
Sub Init()
Set mobjPDFInst = New PXC_Inst
strRelPath = ThisWorkbook.Path & "\" & strPath
Set mobjPDFDoc = mobjPDFInst.OpenDocumentFromFile(strRelPath, Null)
Set mobjFormField = mobjPDFDoc.AcroForm.GetFieldByName("Text1")
mstrText = mobjFormField.GetValueText
End Sub
I tried doing this by looking at the C# code for opening a document and then converting to vb in my Excel document. I have the reference set to the PDF-Xchange PDF Core API Library. I am still getting an error on the line to open the file that an object is needed. I am not sure what I am going wrong. Below is my code. Any help is much appreciated. I am not sure what else to try at this point, but it certainly seems that I should be able to open a document and read a field from the AcroForm according to the documentation.
Thank you!
Thayana
Option Explicit
Private mstrText As String
Private Const strPath As String = "2019 Smith, Joan.pdf"
Private strRelPath As String
Private mobjPDFInst As PDFXCoreAPI.PXC_Inst
Private mobjPDFDoc As PDFXCoreAPI.IPXC_Document
Private mobjFormField As PDFXCoreAPI.IPXC_FormField
Sub Init()
Set mobjPDFInst = New PXC_Inst
strRelPath = ThisWorkbook.Path & "\" & strPath
Set mobjPDFDoc = mobjPDFInst.OpenDocumentFromFile(strRelPath, Null)
Set mobjFormField = mobjPDFDoc.AcroForm.GetFieldByName("Text1")
mstrText = mobjFormField.GetValueText
End Sub
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Read Field Values into Excel
Hi Thayana1977,
Make sure that you are looking at the samples very carefully. You will have to initialize the instance first and finalize it at the end of your program. For more info see this link:
https://sdkhelp.pdf-xchange.com/view/PXV:PXC_Inst
Cheers,
Alex
Make sure that you are looking at the samples very carefully. You will have to initialize the instance first and finalize it at the end of your program. For more info see this link:
https://sdkhelp.pdf-xchange.com/view/PXV:PXC_Inst
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 4
- Joined: Fri Feb 21, 2020 5:02 pm
Re: Read Field Values into Excel
Thanks, Alex. I tried again. I tried the Init passing the GUID for the Core API as given in the documentation both with and without the {}. I still get an "Object Not Found" error on the " Set mobjPDFDoc = mobjPDFInst.OpenDocumentFromFile(strRelPath, Null)" line. The documentation online only goes as far as below for VB6. That being said I think I should be able to call the init right after the set in the example. Any other ideas that I should try? Thanks again! Thayana
Dim pdfInst As PDFXCoreAPI.PXC_Inst
...
Set pdfInst = New PDFXCoreAPI.PXC_Inst
My code:
Option Explicit
Private mstrText As String
Private Const strPath As String = "2019 Smith, Joan.pdf"
Private strRelPath As String
Private mobjPDFInst As PDFXCoreAPI.PXC_Inst
Private mobjPDFDoc As PDFXCoreAPI.IPXC_Document
Private mobjFormField As PDFXCoreAPI.IPXC_FormField
Sub Init()
Set mobjPDFInst = New PXC_Inst
mobjPDFInst.Init ("{D37FFAC6-B7ED-441E-B933-19B4E57FCB60}")
strRelPath = ThisWorkbook.Path & "\" & strPath
Set mobjPDFDoc = mobjPDFInst.OpenDocumentFromFile(strRelPath, Null)
Set mobjFormField = mobjPDFDoc.AcroForm.GetFieldByName("Text1")
mstrText = mobjFormField.GetValueText
mobjPDFInst.Finalize
End Sub
Dim pdfInst As PDFXCoreAPI.PXC_Inst
...
Set pdfInst = New PDFXCoreAPI.PXC_Inst
My code:
Option Explicit
Private mstrText As String
Private Const strPath As String = "2019 Smith, Joan.pdf"
Private strRelPath As String
Private mobjPDFInst As PDFXCoreAPI.PXC_Inst
Private mobjPDFDoc As PDFXCoreAPI.IPXC_Document
Private mobjFormField As PDFXCoreAPI.IPXC_FormField
Sub Init()
Set mobjPDFInst = New PXC_Inst
mobjPDFInst.Init ("{D37FFAC6-B7ED-441E-B933-19B4E57FCB60}")
strRelPath = ThisWorkbook.Path & "\" & strPath
Set mobjPDFDoc = mobjPDFInst.OpenDocumentFromFile(strRelPath, Null)
Set mobjFormField = mobjPDFDoc.AcroForm.GetFieldByName("Text1")
mstrText = mobjFormField.GetValueText
mobjPDFInst.Finalize
End Sub
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Read Field Values into Excel
Hi Thayana1977,
The instance should be initialized with the key that you can buy if everything meets your requirements for proper SDK usage, not the GUID of the interface.
Anyway, what you should do is search the forums for VB topics - there are plenty of answers there and also some sample projects included that should help. The VB can give some unexpected errors that we cannot expect (for example it can be that you are passing the Null value directly or something like that).
Cheers,
Alex
The instance should be initialized with the key that you can buy if everything meets your requirements for proper SDK usage, not the GUID of the interface.
Anyway, what you should do is search the forums for VB topics - there are plenty of answers there and also some sample projects included that should help. The VB can give some unexpected errors that we cannot expect (for example it can be that you are passing the Null value directly or something like that).
Cheers,
Alex
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
-
- User
- Posts: 4
- Joined: Fri Feb 21, 2020 5:02 pm
Re: Read Field Values into Excel
Hi Alex,
Thanks for the info. I did search the forums but didn’t see anything written in VB for what I was trying to do. I will try looking again.
Thank you,
Thayana
Thanks for the info. I did search the forums but didn’t see anything written in VB for what I was trying to do. I will try looking again.
Thank you,
Thayana
-
- User
- Posts: 5522
- Joined: Fri Nov 21, 2014 8:27 am
- Contact:
Re: Read Field Values into Excel
Subscribe at:
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ
https://www.youtube.com/channel/UC-TwAMNi1haxJ1FX3LvB4CQ