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

  • @A7480394
    @A7480394 Жыл бұрын

    This is exactly the level of explanation I like, this video is great! Thanks!

  • @wendywen8794
    @wendywen87947 жыл бұрын

    Super helpful!!!!! Appreciate it!!!!!!!!

  • @rootbeer197
    @rootbeer1978 жыл бұрын

    thank you Alex for sharing your knowledge soooo useful. hugo from québec.

  • @jmtiwari5766
    @jmtiwari57665 жыл бұрын

    This is exactly what i was looking for.

  • @paulwilson-my1mf
    @paulwilson-my1mf6 жыл бұрын

    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.

  • @carlbatten4442
    @carlbatten44429 жыл бұрын

    Is their still a way to use the macro if you have the Adode master collection?

  • @chaimaaadnan9491
    @chaimaaadnan94914 жыл бұрын

    Thanks a lot Alex 👍🏻

  • @tonysparapani3077
    @tonysparapani30776 жыл бұрын

    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?

  • @michaeldelicourt731
    @michaeldelicourt7318 жыл бұрын

    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

  • @vachhanikeyur102
    @vachhanikeyur1029 жыл бұрын

    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?

  • @anomaweerasinghe8805
    @anomaweerasinghe88057 жыл бұрын

    Hi Alex Any program for Nuance PDF converter to extract DATA to an Excel.

  • @pliniomsann
    @pliniomsann9 жыл бұрын

    Nice Alex ... with this code can you also read tables inside the pdf doc? Thank you in advance

  • @nolanbunker8065
    @nolanbunker80655 жыл бұрын

    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.

  • @lawnside82
    @lawnside8211 жыл бұрын

    wow that is so cool!!

  • @eduardomuslimovich9946
    @eduardomuslimovich99467 жыл бұрын

    I already have created the forms in PDF, can you make them be written automatically with this code using Adobe Reader?

  • @marymadyarova5917
    @marymadyarova59175 жыл бұрын

    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.

  • @raymonddarazi9283
    @raymonddarazi92833 жыл бұрын

    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

  • @raymount6438
    @raymount643811 жыл бұрын

    Hi Alex, I have the same issue. How do you add this as a reference? I have X Pro. Thanks, Ray

  • @premkumarramanathan8848
    @premkumarramanathan88488 жыл бұрын

    Hi Alex, can you please help me out with the specific problem I'm facing.

  • @shivamgarg4022
    @shivamgarg40228 жыл бұрын

    Hi Alex, My program runs successfully for PDF read , but no fields are populated in excel?

  • @peterschwarz7526
    @peterschwarz752611 жыл бұрын

    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

  • @agricambo9112
    @agricambo91124 жыл бұрын

    Hi Alex, May I get the code in the Module, please?

  • @premkumarramanathan8848
    @premkumarramanathan88488 жыл бұрын

    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.

  • @kansrk2
    @kansrk211 жыл бұрын

    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?

  • @JoeCoolCols
    @JoeCoolCols11 жыл бұрын

    Can't fin where to down load development kit on Adobe's website. Can only get reference document. can you give a link ?

  • @JoeCoolCols
    @JoeCoolCols11 жыл бұрын

    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?

  • @vijayaganeshv5766
    @vijayaganeshv57666 жыл бұрын

    What is the variable assigned for Fields

  • @islahiyette1
    @islahiyette15 жыл бұрын

    hi i want write a specific watermark to each pdf page in vba i habe 500 pages

  • @JoeCoolCols
    @JoeCoolCols11 жыл бұрын

    Sorry for mutiple comments.could you show or describe how to add a reference ? Thanks, Joe

  • @JoeCoolCols
    @JoeCoolCols11 жыл бұрын

    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

  • @wesleyab80
    @wesleyab8011 жыл бұрын

    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!

  • @JoeCoolCols
    @JoeCoolCols11 жыл бұрын

    Could you show how to set this up in a video? Thanks, Joe

  • @psrc08
    @psrc087 жыл бұрын

    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

    @seekknowledge2714

    6 жыл бұрын

    Mr. Peibol You can try the *OpenURL* method or *Thisworkbook.FollowHyperlink* any of them should does the job

  • @asterion70
    @asterion703 жыл бұрын

    Thanks a lot

  • @taimoorkhan8203
    @taimoorkhan82037 жыл бұрын

    how can i insert a water mark in to a PDF document created by a macro

  • @fortak2006
    @fortak20069 жыл бұрын

    Hi Alex this tutorial is useful, could you mind sharing the code to me?thank you so much

  • @jamisonrobert1
    @jamisonrobert14 жыл бұрын

    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?

  • @andyjin7257
    @andyjin72579 жыл бұрын

    Hi Alex. Nice video. Could you share your code?

  • @yuxie5743
    @yuxie57436 жыл бұрын

    how can I find the code?

  • @domzkyofficial7029
    @domzkyofficial70293 ай бұрын

    Can i copy your code..for easy edit on macros.

  • @noahjulianramseur1471
    @noahjulianramseur14713 жыл бұрын

    Does not work. Keep getting Compile error: Variable not defined. Running excel 2016 on Windows 10.

  • @SixSigmaGuy
    @SixSigmaGuy9 жыл бұрын

    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

    @alexcantu3

    9 жыл бұрын

    Please check description. Thank you for watching. :)

  • @blakemaster5054
    @blakemaster50545 жыл бұрын

    Hi may I ask you please

  • @JoeCoolCols
    @JoeCoolCols11 жыл бұрын

    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

    @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.

  • @simao0505
    @simao05054 жыл бұрын

    Is Adobe Pro for free?

  • @rsmaster5637
    @rsmaster56374 жыл бұрын

    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 ?

  • @JoeCoolCols
    @JoeCoolCols11 жыл бұрын

    Nevermind about the question see now you have to regiseter with adobe to down load the SDK

  • @JoeCoolCols
    @JoeCoolCols11 жыл бұрын

    Never mind see now that you have to register with adobe to download the sdk.

  • @AndresDiaz-pf8ve
    @AndresDiaz-pf8ve11 жыл бұрын

    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

    @nolanbunker8065

    6 жыл бұрын

    I ran into the same issue, was there any fix to this?

  • @brianduran3676
    @brianduran367610 жыл бұрын

    Where can i get the code that your wrote?

  • @Careco1965

    @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

  • @neethupaulson4216
    @neethupaulson42167 жыл бұрын

    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

    @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

  • @walterkendall170
    @walterkendall1707 жыл бұрын

    Hi Alex. Great video. I can't find the code in any of the comments. Could you repost? Thanks.

  • @alexcantu3

    @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

    @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

  • @JoeCoolCols
    @JoeCoolCols11 жыл бұрын

    Ok, found out the problem was moving it to another directory even though I copied the SDK File to the same directory

  • @ravipunai6767
    @ravipunai676710 жыл бұрын

    I cannot get the code to compile. I keep getting user-defined type not defined. I am using Acrobat x Pro

  • @davidfunvideos

    @davidfunvideos

    8 жыл бұрын

    +Ravi Punai did you ever find a solution to this? I am having the same trouble?

  • @JoeCoolCols
    @JoeCoolCols11 жыл бұрын

    Nevermind see you have to register to download

  • @r.a.8618
    @r.a.86185 жыл бұрын

    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

    @Lutfitince

    4 жыл бұрын

    Good day bro, did you find any solutions?

  • @zahidthakur8725

    @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

  • @JoeCoolCols
    @JoeCoolCols11 жыл бұрын

    Never mind see you have to sign up first

Келесі