Open PDF and copy/paste into excel

MIRA7

New Member
Joined
Dec 19, 2016
Messages
25
Good day
I have a pdf document of 85 pages.
I would like to:
1) open the pdf document
2) copy the data on the pdf document
3) paste it into excel
4) Repeat step 2 and 3 for each page of the pdf.
Thanks
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
ok so, I was able to write a code for the request above, however, I get an erro with adobe that says" there was an error opening this document. Access denied".
Can anyone help? Thanks.

Code:
Dim AdobeApp As String
Dim AdobeFile As String
Dim StartAdobe
 
AdobeApp = "C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe"
AdobeFile = "M:\test\car1\Unit114\Combined M641-1T14.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
The error might be caused by spaces in the Adobe program path or PDF file path.

Try surrounding the strings with quotes by changing the Shell line to:
Code:
    StartAdobe = Shell(Q(AdobeApp) & " " & Q(AdobeFile), 1)
which calls this function:
Code:
Private Function Q(text As String)
    Q = Chr(34) & text & Chr(34)
End Function
 
Last edited:
Upvote 0
Thank you - I am able to open the PDF now.

However, I am getting a error message that says --- """Cannot run the macro "C:\users\myoung\documents\copy pdf to excel.xlsm'!FirstStep'. The macro may not be available in this workbook or all macros may be disabled"""

Do you know why?
 
Upvote 0
Also you can convert your PDF document ---> (Online Convert pages) Convert PDF files to Microsoft Excel documents, extract tables. Use the Select File ... button to locate the PDF document on your computer and click the Convert button.
You can select the datas you want to copy from the converted file.
 
Upvote 0
Thanks - but I have tried it and it doesn't work because of the document content.
I do have to copy PDF content and paste it in Excel for me to extract what I need. Conversion wont work with me unfortunately.
 
Upvote 0
Thank you - I am able to open the PDF now.

However, I am getting a error message that says --- """Cannot run the macro "C:\users\myoung\documents\copy pdf to excel.xlsm'!FirstStep'. The macro may not be available in this workbook or all macros may be disabled"""

Do you know why?
Where have you put the code? That error can occur if the code, specifically the OnTime macros, is in a sheet module. The easiest solution is to put all the code in a standard module.
 
Upvote 0
Thanks - I did put it in a module now and it looks like I'm almost there.
But It gives me an Run-time error'5': Invalid procedure call or argument .........and it highlights in yellow this line for me:
Code:
AppActivate "Microsoft Excel"
 
Upvote 0
I have tried to replace the code
Code:
AppActivate "Microsoft Excel"
by
Code:
ActiveWorkbook.Sheets("COPY").Select

and it copies the content of the PDF document on the module code itself and not on the excel worksheet.
 
Upvote 0

Forum statistics

Threads
1,213,495
Messages
6,113,992
Members
448,538
Latest member
alex78

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