Read\Write to PDF Files using Microsoft Excel VBA Programming
Ғылым және технология
This video shows how to programatically read\write to a PDF file using Microsoft Excel 2010/2007 using PDF API. Using Excel, you can read\write to PDF fields and other controls.
Note: Remember to add your Adobe Acrobat Library in the VB Environment. Tools, References, Select the Adobe Acrobat Library. This does require Adobe Pro*
Handy Excel Resources
amzn.to/3gFx7s1 - Excel Formulas & Functions For Dummies 5th Edition
amzn.to/3sYnuH6 - Microsoft Excel 2019 VBA and Macros
amzn.to/2PqXhU0 - MICROSOFT EXCEL VBA AND MACROS FOR BEGINNERS:
amzn.to/3xtsLtM - Microsoft Excel VBA Programming for the Absolute Beginner
amzn.to/3xwkEg0 - Excel 2019 Bible
amzn.to/3aJEHxW - EXCEL 2020 FOR BEGINNERS
As an Amazon Associate, I earn from qualifying purchases. Product prices and availability are subject to change.
Пікірлер: 73
This is exactly the level of explanation I like, this video is great! Thanks!
Super helpful!!!!! Appreciate it!!!!!!!!
thank you Alex for sharing your knowledge soooo useful. hugo from québec.
This is exactly what i was looking for.
Hi Alex, Thank you so much for this tutorial, I was trying to do this with sendkeys without too much success. I have AdobePro is there a way to SaveAs the file which I have just updated? I have numerous sheets which work off of the same base template pdf document and the saveas ability would be the answer. Thanks again for this explanation.
Is their still a way to use the macro if you have the Adode master collection?
Thanks a lot Alex 👍🏻
I like your code and i think i would have a use for it, however i tried to use it and it wont work with my 2016 excel. Is there an adaptation that you could share?
Hi Alex, My version of Acrobat allows me to manually insert a "stamp" inside a pdf document. Would it be possible to automate this manual operation through VBA? thanks
Hi Alex, nice video. I want to make a script that automatically adds the links in to single pdf file. For example if I click on the any section mentioned in the index/ table of content, It should get redirected to that same section below in the same PDF. Script (in either VBA or C# or Javascript) without using acrobat is preferred. Can you help me in this?
Hi Alex Any program for Nuance PDF converter to extract DATA to an Excel.
Nice Alex ... with this code can you also read tables inside the pdf doc? Thank you in advance
Hello Alex, I am currently trying to something similar to your video; however, the code you use in this video will not work for me. What adobe reference(s) do you have selected in the VBA tools. Thank you.
wow that is so cool!!
I already have created the forms in PDF, can you make them be written automatically with this code using Adobe Reader?
Alex, Do you know how to get and change coordinates of a specific text (Ex. "Figure 1" in the right coner) on a PDF page. PDF page has only text. I am writing VBA code and cannot figure it out.
Hello Alex, Thank you so much for this great video / tutorial. It works great but still missing the SAVE. Kindly let us know how to save the PDF file. Thank you, Raymond Darazi
Hi Alex, I have the same issue. How do you add this as a reference? I have X Pro. Thanks, Ray
Hi Alex, can you please help me out with the specific problem I'm facing.
Hi Alex, My program runs successfully for PDF read , but no fields are populated in excel?
Hi, thanks for the files. after loading in the references to adobe, i'm getting an error on this line of code... If AcrobatDocument.Open(filepath & datafile, "") Then the error is "object variable or with block variable not set" run-time error 91 any help would be appreciated. peter
Hi Alex, May I get the code in the Module, please?
Hi Alex, first of all thanks for putting out a useful video in youtube. I'm running a trial version of Adobe Acrobat Pro DC and Excel 2010 on my system. Despite included Adobe Acrobat 10.0 Type Library into VBA references, I'm seeing that the acrobatapplication in the declaration and statment Dim acrobatapplication As Acrobat.CAcroApp Set acrobatapplication = CreateObject("AcroExch.App") are not changing to proper case and its not working. Please help me out.
I have a huge PDF with 6000 pages that I need to split into multiple PDF files based on page numbers I have listed in an Excel spreadsheet. Can I do this using an Excel VB Macro?
Can't fin where to down load development kit on Adobe's website. Can only get reference document. can you give a link ?
HI Alex, I used your code to get the names off fields in my document. Instead of looking like the ones you have, mine have names like Debtor.Name, Claim.Amount etc. the values look just like the values in the PDF.When I try your code to write Fields("Debtor.Name").Value = "minnie mouse" I don't get any errors but it won't write to the field. I need to use a variable for my program in the place of the literal "minnie mouse". That doesn't work either. What am I doing wrong?
What is the variable assigned for Fields
hi i want write a specific watermark to each pdf page in vba i habe 500 pages
Sorry for mutiple comments.could you show or describe how to add a reference ? Thanks, Joe
Alex this video is great but when I put the code in an excel sheet, I get user-defined type not defined on this line Dim AcrobatApplication As Acrobat.CAcroApp. Is there a library i have to add and could you do a step by step on adding the library? Don't know how to email or message on here, but also posted on the page for the group. Don't see it now though. Thanks,Joe
great video! One more help: I need it to call the pdf to open in Adobe Reader and not Acrobat. That means I need to "Set AcrobatApplication = CreateObject("???????") and "Set AcrobatDocument = CreateObject("???????") Help!
Could you show how to set this up in a video? Thanks, Joe
Hi Alex, im really stuck at one point of my program, hope that if you have a little time might help, I just want to print several pdf files from a VBA in Excel, but I've tried some codes and different methods to do it but non has done the job, even with the shell command. Do you have any info that I might use? Thanks in advance anyway...
@seekknowledge2714
6 жыл бұрын
Mr. Peibol You can try the *OpenURL* method or *Thisworkbook.FollowHyperlink* any of them should does the job
Thanks a lot
how can i insert a water mark in to a PDF document created by a macro
Hi Alex this tutorial is useful, could you mind sharing the code to me?thank you so much
I can't seem to get this to work with Acrobat DC and Excel 2016. When I run "Dim AcrobatApplication As Acrobat.CAcroApp" I get a message "User-defined type not defined." Any ideas?
Hi Alex. Nice video. Could you share your code?
how can I find the code?
Can i copy your code..for easy edit on macros.
Does not work. Keep getting Compile error: Variable not defined. Running excel 2016 on Windows 10.
Hi Alex, nice video. But I'm confused; I see several times in the comments where people ask you about the reference that needs to be added. Why don't you answer them? I have the same question. When I go to the add reference dialog, what reference do I choose from the list? Or which dll, etc., do I have to browse to and add?
@alexcantu3
9 жыл бұрын
Please check description. Thank you for watching. :)
Hi may I ask you please
I was wondering if you could give the code for saving the PDF under a different name to a different dir after we fill it in. AcroExch.AVDoc doesn't seem to have a save method because I get methos not found. Seems like it has an open it should have a save.
@r.a.8618
5 жыл бұрын
Hi, I would also like to know how to save as a new file. If you found a solution to this, could you please share? Thanks a lot.
Is Adobe Pro for free?
Hello! Very Nice Function... There is only one Problem.. When Writing to the PDF ,the PDF Programm Dont Closes at the End of Writing Data To it.. First i found a Problem That it Stucks on the Save As Promt. After Solving the File Save Issue the PDF Program Stays Open and i have to shut down Manualy ... The .Exit Function does Nothing..... Has Anyone the Same Problem or Found a Solution ?
Nevermind about the question see now you have to regiseter with adobe to down load the SDK
Never mind see now that you have to register with adobe to download the sdk.
Hi Alex, I used your code and when I run the the macro, VB gives me an error. "Compile error: User-defined type not defined". After clicking "OK" it highlights:AcrobatApplication As Acrobat.CAcroApp. I like the idea of using this macro. Pleeeeease HELP. Thanks,
@nolanbunker8065
6 жыл бұрын
I ran into the same issue, was there any fix to this?
Where can i get the code that your wrote?
@Careco1965
3 жыл бұрын
Sub WriteAdobeFields() 'topmostsubform[0].f2_12_0[0] 'This video shows how to programatically read\write to a PDF file using Microsoft Excel 2010/2007 using PDF API. Using Excel, you can read\write to PDF fields and other controls. 'Note: Remember to add your Adobe Acrobat Library in the VB Environment. Tools, References, Select the Adobe Acrobat Library. This does require Adobe Pro* Dim AcrobatApplication As Acrobat.CAcroApp Dim AcrobatDocument As Acrobat.CAcroAVDoc Dim fcount As Long Dim sFieldName As String Set AcrobatApplication = CreateObject("AcroExch.App") Set AcrobatDocument = CreateObject("AcroExch.AVDoc") If AcrobatDocument.Open("S:\INVOICE SYSTEM For IZ Ready TO USE_New\All_Foms2.pdf", "") Then AcrobatApplication.Show Set AcroForm = CreateObject("AFormAut.App") Set Fields = AcroForm.Fields fcount = Fields.Count ' Number of Fields Fields("VIN54321").Value = "VIN Baba" ' Works! Else MsgBox "failure" End If AcrobatApplication.Exit Set AcrobatApplication = Nothing Set AcrobatDocument = Nothing Set Field = Nothing Set Fields = Nothing Set ActoForm = Nothing End Sub Sub ReadAdobeFields() row_number = 1 Dim AcrobatApplication As Acrobat.CAcroApp Dim AcrobatDocument As Acrobat.CAcroAVDoc Dim fcount As Long Dim sFieldName As String 'On Error Resume Next Set AcrobatApplication = CreateObject("AcroExch.App") Set AcrobatDocument = CreateObject("AcroExch.AVDoc") If AcrobatDocument.Open("S:\INVOICE SYSTEM For IZ Ready TO USE_New\All_Foms2.pdf", "") Then AcrobatApplication.Show Set AcroForm = CreateObject("AFormAut.App") Set Fields = AcroForm.Fields fcount = Fields.Count ' Number of Fields For Each Field In Fields row_number = row_number + 1 sFieldName = Field.Name 'MsgBox sFieldName Sheet4.Range("B" & row_number) = Field.Name Sheet4.Range("C" & row_number) = Field.Value 'Sheet1.Range("D" & row_number) = Field.Style Next Field Else MsgBox "failure" End If AcrobatApplication.Exit Set AcrobatApplication = Nothing Set AcrobatDocument = Nothing Set Field = Nothing Set Fields = Nothing Set ActoForm = Nothing End Sub
Alex i would like to know if its possible to capture data from excel to PDF forms. For example - i have a PDF Doucument already but i need to fill the PDF Form capturring the data from Excel sheet as i enter the details. Is it possible. Please help.
@ExcelForFreelancers
6 жыл бұрын
Hi, i know that you requested this a long time ago, however I have created a solution for this, that does not require reference libraries or Acrobat Pro here: kzread.info/dash/bejne/p4lpl6h8krOuc6w.html
Hi Alex. Great video. I can't find the code in any of the comments. Could you repost? Thanks.
@alexcantu3
7 жыл бұрын
Code isn't in comments. Watch the video in 720P to clearly view code. That source is long gone, I don't have it anymore.
@Careco1965
3 жыл бұрын
Sub WriteAdobeFields() 'topmostsubform[0].f2_12_0[0] 'This video shows how to programatically read\write to a PDF file using Microsoft Excel 2010/2007 using PDF API. Using Excel, you can read\write to PDF fields and other controls. 'Note: Remember to add your Adobe Acrobat Library in the VB Environment. Tools, References, Select the Adobe Acrobat Library. This does require Adobe Pro* Dim AcrobatApplication As Acrobat.CAcroApp Dim AcrobatDocument As Acrobat.CAcroAVDoc Dim fcount As Long Dim sFieldName As String Set AcrobatApplication = CreateObject("AcroExch.App") Set AcrobatDocument = CreateObject("AcroExch.AVDoc") If AcrobatDocument.Open("S:\INVOICE SYSTEM For IZ Ready TO USE_New\All_Foms2.pdf", "") Then AcrobatApplication.Show Set AcroForm = CreateObject("AFormAut.App") Set Fields = AcroForm.Fields fcount = Fields.Count ' Number of Fields Fields("VIN54321").Value = "VIN Baba" ' Works! Else MsgBox "failure" End If AcrobatApplication.Exit Set AcrobatApplication = Nothing Set AcrobatDocument = Nothing Set Field = Nothing Set Fields = Nothing Set ActoForm = Nothing End Sub Sub ReadAdobeFields() row_number = 1 Dim AcrobatApplication As Acrobat.CAcroApp Dim AcrobatDocument As Acrobat.CAcroAVDoc Dim fcount As Long Dim sFieldName As String 'On Error Resume Next Set AcrobatApplication = CreateObject("AcroExch.App") Set AcrobatDocument = CreateObject("AcroExch.AVDoc") If AcrobatDocument.Open("S:\INVOICE SYSTEM For IZ Ready TO USE_New\All_Foms2.pdf", "") Then AcrobatApplication.Show Set AcroForm = CreateObject("AFormAut.App") Set Fields = AcroForm.Fields fcount = Fields.Count ' Number of Fields For Each Field In Fields row_number = row_number + 1 sFieldName = Field.Name 'MsgBox sFieldName Sheet4.Range("B" & row_number) = Field.Name Sheet4.Range("C" & row_number) = Field.Value 'Sheet1.Range("D" & row_number) = Field.Style Next Field Else MsgBox "failure" End If AcrobatApplication.Exit Set AcrobatApplication = Nothing Set AcrobatDocument = Nothing Set Field = Nothing Set Fields = Nothing Set ActoForm = Nothing End Sub
Ok, found out the problem was moving it to another directory even though I copied the SDK File to the same directory
I cannot get the code to compile. I keep getting user-defined type not defined. I am using Acrobat x Pro
@davidfunvideos
8 жыл бұрын
+Ravi Punai did you ever find a solution to this? I am having the same trouble?
Nevermind see you have to register to download
I tested it and it actually worked in my computer! Could you please also explain how I can save the PDF file filled in by VBA? I tried both AcrobatDocument.Save and AcrobatDocument.SaveAs but they don't work neither. Instead I got a compile error that said 'Method or data member not found.' I would like to write a for loop program to automate the whole process from filling in the PDF form to saving it as a new file. This is the last and only part where I'm stuck. I would really appreciate if you could give some advise. Thanks.
@Lutfitince
4 жыл бұрын
Good day bro, did you find any solutions?
@zahidthakur8725
Жыл бұрын
Hi bro..were you able to achieve complete your code. I tried the code mentioned in the mail but instead I am getting a error stating pdf access declined
Never mind see you have to sign up first