PDF to Excel data copy

vinny2984

Board Regular
Joined
Sep 22, 2008
Messages
202
Does anyone if its possible to write code that will select all in a pdf and copy paste to excel?
I've used the following code to get the PDF file open, which works fine, but thats where it stops for me. If its possible I'd like to be able to continue the code to select all in the PDF doc and paste into excel.
Any ideas?
Thanks

Code:
Shell "C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exe C:\users\richard\desktop\RDS\Richard Pay form.pdf"
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
Reason I asked was because it might be related to the app not being found not just the file...
 
Upvote 0
version 8.0, but i changed that in the code

Hello All,
I am new here. I have been following this thread, trying to copy pdf to excel. I have used the codes suggested but having the same challenge as Emmily had. I am using adobe reader 8.0 and am working with excel 2003. Please I need urgent help.
 
Upvote 0
Hey i used this code it worked perfect but my problem is that my PDF file has several pages and this code just copys the first page so any idea if there is any possibility to copy all pages?


Hey Vinny, try tinkering with SENDKEYS (sending keys: ctrl+a to select all, ctrl+c to copy and ctrl+v to paste). Below is a simple example. I also used Application.OnTime to allow time for the application to open and time for copying (you can change the timing to suit your needs - it set for 5 second delay on opening and 10 second delay on copying). As a side note, it has always been my experience that copying from PDF files into Excel makes a yucky mess as it always loses its pretty PDF formatting:


Code:
Sub StartAdobe()
 
Dim AdobeApp As String
Dim AdobeFile As String
Dim StartAdobe
 
AdobeApp = "C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exe"
AdobeFile = "C:\users\richard\desktop\RDS\Richard Pay form.pdf"
 
StartAdobe = Shell("" & AdobeApp & " " & AdobeFile & "", 1)
 
Application.OnTime Now + TimeValue("00:00:05"), "FirstStep"
 
End Sub
 
Private Sub FirstStep()
 
SendKeys ("^a")
SendKeys ("^c")
 
Application.OnTime Now + TimeValue("00:00:10"), "SecondStep"
 
End Sub
 
Private Sub SecondStep()
 
AppActivate "Microsoft Excel"
 
Range("A1").Activate
SendKeys ("^v")
 
End Sub
 
Upvote 0
Hi Vinny, you can add another SENDKEYS function (see below revised SecondStep procedure - the item in bold face red is what I added.). By the way, when I was doing all this the only App I had open was Excel. So having other apps open will running the macro could cause unexpected results (e.g. if Adobe was already open). I was hoping you would use this as a general guide to provide you with some direction...any further enhancements are up to you.

Rich (BB code):
Private Sub SecondStep()
 
SendKeys ("%fx")
 
AppActivate "Microsoft Excel"
 
Range("A1").Activate
 
SendKeys ("^v")

End Sub
Hi Crimson,

i used this code and it worked perfectly but my problem is that my PDF file has several pages but this code copies just the first page is there any possibility that i can copy all pages?
 
Upvote 0
Hi crimson,
Thank you for this code i want more help in this code you select all pdf file but i don't want to this.

I want to select particular text from pdf file. will you please help me. i selected text on pdf and automation is copy selected text and paste into excel file.
 
Upvote 0
Dear Sir,

I used this code but doesn't work. I want to open pdf file and copy text from pdf and paste in doc file by using mouse selected text only not whole pdf file please suggest vba code for this

Regards
:confused:

Crimson, many thanks it works perfectly. Your right, if the pdf is already open it crashes, so i'll play with that to see if i can check if its open before it attempts to open.
Below is the code i used, which is exacly what you sent. There's been no need to change it.
brilliant, thanks

Code:
Sub StartAdobe()
Dim AdobeApp As String
Dim AdobeFile As String
Dim StartAdobe
 
AdobeApp = "C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exe"
AdobeFile = "C:\users\richard\desktop\RDS\Richard Pay form.pdf"
 
StartAdobe = Shell("" & AdobeApp & " " & AdobeFile & "", 1)
 
Application.OnTime Now + TimeValue("00:00:05"), "FirstStep"
End Sub
Private Sub FirstStep()
SendKeys ("^a")
SendKeys ("^c")
 
Application.OnTime Now + TimeValue("00:00:10"), "SecondStep"
 
End Sub
 
Private Sub SecondStep()
SendKeys ("%fx")
AppActivate "Microsoft Excel"
ThisWorkbook.Activate
Sheets(1).Activate
Range("A1").Activate
SendKeys ("^v")
End Sub
 
Upvote 0
Dear Sir,

I tried this code but its open only PDf file, I want that after opened PDF file it should automatically copy mouse selected text and paste in new doc file.

Thanks
:confused:


Hey Vinny, try tinkering with SENDKEYS (sending keys: ctrl+a to select all, ctrl+c to copy and ctrl+v to paste). Below is a simple example. I also used Application.OnTime to allow time for the application to open and time for copying (you can change the timing to suit your needs - it set for 5 second delay on opening and 10 second delay on copying). As a side note, it has always been my experience that copying from PDF files into Excel makes a yucky mess as it always loses its pretty PDF formatting:


Code:
Sub StartAdobe()
 
Dim AdobeApp As String
Dim AdobeFile As String
Dim StartAdobe
 
AdobeApp = "C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exe"
AdobeFile = "C:\users\richard\desktop\RDS\Richard Pay form.pdf"
 
StartAdobe = Shell("" & AdobeApp & " " & AdobeFile & "", 1)
 
Application.OnTime Now + TimeValue("00:00:05"), "FirstStep"
 
End Sub

Private Sub FirstStep()

SendKeys ("^a")
SendKeys ("^c")
 
Application.OnTime Now + TimeValue("00:00:10"), "SecondStep"
 
End Sub
 
Private Sub SecondStep()
 
AppActivate "Microsoft Excel"
 
Range("A1").Activate
SendKeys ("^v")

End Sub
 
Upvote 0

Forum statistics

Threads
1,215,053
Messages
6,122,882
Members
449,097
Latest member
dbomb1414

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top