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

Round to nearest half hour?
Use =MROUND(A2,"0:30") to round to nearest half hour. Use =CEILING(A2,"0:30") to round to next half hour.
Yes, the same code, but with these lines changed to suit your environment:
Code:
AdobeApp = "C:\Program Files (x86)\Adobe\Reader 11.0\Reader\AcroRd32.exe"   'Adobe Reader executable
AdobeFile = "C:\folder\path\Index Historical Performance.pdf"
 
Upvote 0
This waiting in-line method, instead of via Application.OnTime, also works:
Code:
Public Sub Copy_and_Paste_From_PDF_File2()

    Dim AdobeApp As String
    Dim AdobeFile As String
    Dim StartAdobe
     
    ActiveSheet.Cells.Clear
    
    AdobeApp = "C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe"
    AdobeFile = "C:\Folder\Path\File.pdf"
   
    StartAdobe = Shell(Q(AdobeApp) & " " & Q(AdobeFile), 1)
    
    'Wait 3 seconds to allow PDF to open
    Application.Wait DateAdd("s", 3, Now)
    
    'Select All and Copy from PDF
    SendKeys "^a^c", True
    
    'Wait 5 seconds to allow Select All and Copy to finish
    Application.Wait DateAdd("s", 5, Now)
    
    'Paste into Excel
    AppActivate Application.Caption
    ActiveSheet.Range("A1").Select
    SendKeys "^v", True
   
End Sub
 
Upvote 0
I am getting a Compile error:

Invalid outside Procedure?

Just FYI I plugged into VBA the code above. Is that the correct process?

Thanks
 
Upvote 0
The code should go in a module. But that error means you've put something in the wrong place. If you post your entire code then I can check it.
 
Upvote 0

Forum statistics

Threads
1,214,649
Messages
6,120,733
Members
448,987
Latest member
marion_davis

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