VBA to read contents from PDF File - VBA PDF Automation-3

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
before we start writing the code let's quickly copy the file path and now I'm gonna create a new workbook let's insert a new module and create a public constant variable called PDF underscore file and we'll store our file path here we'll create a sub procedure called read from PDF and before we start writing the code we'll reference it to Adobe Acrobat library just make sure you reference it to the latest version I have 10.0 there now let's start declaring variables the app will be our acrobat application every document this will be our acrobat viewer now let's replicate this for PDF dog this will be PD dog and select X variable again all these are object variables in the page we're gonna select the text later this is for the page corner and the text corner we're going to look through later on we're gonna use this and then this will be the page numbered content please content and the content itself within the page now let's set the variables creating object we'll create an object for a VAR a B dock as well now we'll open the PDF document adding a quick handler in case if it fails to open it will exit sup now we'll try to reference and get the active document in this slow I'm gonna add a reference to get the active document from the application Hey app is okay now I'm gonna reference this PDF RP a PDF underscore dog to the AV dog then we'll be exposed to the methods from the from the AV dog for PDF talk now I'm gonna look true from for all the pages the counter start from zero we'll have to subtract one from the pages so within this look we're gonna reference I will create this page page number content and and so on okay creating an object again for page content this is this particular object is basically gonna highlight highlight tags or contents within the page and then we'll discounters is basically we're selecting all the text from 0 to 9,000 you might want to add more if your page have more condensed adding a quick error handler in case it returns an error when we try to select the text within the page select Isis using the page highlight page content from the page content okay now we'll start looping through all the all the text within from the selection or j.j counter is going to take care of that again looping from 0 till all the total and let's print this value to our immediate window that's pretty much it our we're gonna review it later after we write everything let's quickly clean the memory so make sure that once it finished running it clears out the memory so the next time it runs it's ok we're gonna close the PDF document there without saving it false stands for that we're gonna exit the application and then we're just gonna set all these variables to nothing all the object variables so I keep on compiling there just to make sure that it compiles okay though this art hard party API is so it might even if it compiles okay maybe it will not be 100% working but then we'll have to run and test it out quickly we'll have to change this from read from PDF the typos and looks like we have to add it should be yeah it should be big content add okay so let's quickly check out our code and make sure it's working I'm gonna quickly turn on the immediate window and try to run this code so I'm gonna hit f8 and quickly go through the code so it's starting to print out the data from PDF okay I'm gonna run the rest of the code let's extract all the data but since it's too much of data really doesn't make sense we print it out here in a mediate window let's try to transfer the same data to the to the worksheet here just say range let's print this out to column a okay I think that should do Oh call this PDF and I'm gonna execute this it's super quick it extracted all the data now I'm gonna quickly open the PDF file and do a quick recon so as you can see here the top flows report and the date is here in the PDF and then the Adobe Acrobat is this the paragraph starting from here and then so on so as you can see the data that is being pulled from PDF is not coming in the exact format that we need so in the following video we're gonna put in some additional logics to pull in data from the table from this particular PDF you
Info
Channel: VBA A2Z
Views: 62,272
Rating: undefined out of 5
Keywords: pdf to exce, convert pdf to excel, extract pdf data, pdf data extract, extract pdf form data, extracting pdf form data, extract pdf data to excel, excel data from pdf, excel data from pdf form, pdf form data extracted, pdf to excel, pdf extracted to excel, pdf to excel table, pdf form to excel table
Id: ZWizyQ8_9s0
Channel Id: undefined
Length: 8min 54sec (534 seconds)
Published: Thu Jan 16 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.