Read\Write to PDF Files using Microsoft Excel VBA Programming

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone in this video I'm going to demonstrate how we can get information from Microsoft Excel and place it into an Adobe PDF document and I'm also going to show how we can read information from a PDF document now the code that I use in this is we're going to be using the Visual Basic environment a lot of this code was put together using adobe's developers U developers website where they have information about how you can use API to pull data from a PDF document or other Adobe programs so what we're going to do here is I'm going to give you a quick demonstration I have two fields that have already been written we have R Adobe fields and then we have right to Adobe Fields so first I'm going to go over the read Adobe Fields I have a document that's already open test one.pdf it's a W4 form and I have some values already in here but we can just erase them out but for the sake of this test I'm going to just put in some numbers here 1 2 3 4 5 and six just for Fields a through F I mean this form is a lot bigger and I'm just going to put in first name and last name and we'll just put in a fake Social and what I'm going to do is go to Microsoft Excel now um might I say really quick test one.pdf is located in one of my folders so I'm going to do read Adobe field builds and what we're going to first do we're going to call the Adobe application give me a a second before I explain the code let me just play it out so you can see what it does I'm going to run the macro that says read Adobe fields and hit run and what it's doing for you to the to the left we have column B this gives you the name of the field like what the name of the the property is and in this case if you're familiar with computer programming like a user form every field that you have has a name so like if I I just drew a user form right here we have a text box if we were to right click that and click properties the name of this field is textbox one so what we're doing over here though what's in column B is the name of the field that's in the PDF document so in this case this field right here is where we have the first name so let me go to the document this box right here the name of this box is this field is is this name right here where we have the numbers 1 2 3 4 5 6 which we put as a through F these are the name of of those of those fields so let me go on and go back to the code now the other procedure that I have is write to Adobe Fields so what I've done here is I'm writing to two fields and the field that I have set here is the first name which is f109 0 and that's exactly the one that I place right here so if also put changes out to test name and then we I'm going to play the code now hit run I toggle back to my Adobe test one file actually have to click out of it so let me click out there it can't be an active field it has to be um unactive so let me try this again actually no they test name it's it's set so let's just do this one more time Visual Basic we'll just do it to testing one two 3 and we're going to play the code click run and there you have it the first name has been changed to testing one two 3 and the way I wrote to it again is by using the name of these fields over here I knew that the first name field that this was the name and in Visual Basic we used right here Fields place the name that you wanted the name of the field that you want to change value and then change it to testing 123 so to briefly explain how how these work again a lot of this code is from from acrobats developers Network Forum one of the first things that you're going to have to do is declare all your variables and of course the call to the application so you have your your declarations onor resume next you don't necessarily need this but this is just in case you come across any errors for example field. style this property is not available in every single field in the in this Adobe document for example these fields right here ver name last name social home address city state and zip don't have that property where you have the field. style but you these check boxes over here do have a style because that's that's a checkbox style but the on aor resume next you don't need that that's just in case if the program comes across any errors it just goes to to The Next Step but what you're going to do here though is you have to call the Adobe Acrobat um application then we have to call the document and this is where we're actually opening the document so to customize this for your code what you're going to want to do is put in your directory and your your path to your PDF file that you want to open you want to show the application and what we're going to do this is going to be the important part you don't need to make any changes to this but what you're going to do here in this repetition this is just going to be going through each field and what I'm doing here is reading the name name the value and the style the name being the name of the box which is where the demonstration I shows you in the user form as to each field has a name the value in this case what's actually in the box and D the style uh as as I mentioned earlier a lot of these boxes they don't have a style but the check boox does have a style which you see in in that it was written out in column DS it was being outputed and then all this portion down here just clears all the instances of of the calling of the Adobe document and the Adobe application right into the Adobe Fields is is is rather it's it's more simple than this code because we're not doing any kind of repetitions all we're doing is the same declarations we're calling the document and once you call the document it's just a matter of just putting the fields in so if we wanted to put in the last name just going to give you one more example the last name we already knew uh that this is the field name just going to copy this code copy that name and we're just going to change this how we're just going to do fields. value this is the last name and I'm just going to play this code now right to Adobe Fields run we click outside the box last name this is the last name so this just gives you a real quick demonstration on how you can read a PDF document and how you can write to it now you may not be able to save to it because you would need Adobe professional to do that but I mean if you do have Adobe professional this can really help you out because I can tell you from a business standpoint um a lot a lot of times we might have a an open database connection where we have data in the back end and we may have Fields where we have first name last name and we may need to quickly populate a PDF file and this is one quick way to do it so I really hope you enjoyed this video I'm going to have this code posted into the YouTube description a I mean it's not all going to fit but I'll have it posted in in multiple comments so I hope you enjoyed this video thank you for watching
Info
Channel: Alex C
Views: 77,948
Rating: undefined out of 5
Keywords: Write to PDF File, Read PDF File, Read PDF file with Excel, Write PDF file with Excel, VBA PDF Programming, Read PdF using VBA, Write PDF using PDA, Excel 2010 VBA PDF Training
Id: aw_Q7aIEc8c
Channel Id: undefined
Length: 8min 22sec (502 seconds)
Published: Thu Nov 08 2012
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.