Copying from PDFs using rectangles

reuben9000

New Member
Joined
Feb 8, 2015
Messages
6
Hi All,

So basically I am trying to create a macro which will open up a specified PDF file and copy the text on each page within a particular area onto Excel. In all honesty, I'm not quite sure why my code isn't working, seems fine to me. Can anyone help me out? I've attached the code below. Nothing seems to be pasting in Excel but the document is opening.
Thanks in advance!

Sub NewTestMacro()
Dim AcrobatApp As Acrobat.AcroApp
Dim AcrobatDocument As Acrobat.AcroAVDoc
Dim pdfDoc As Acrobat.AcroPDDoc
Dim Rect As Acrobat.AcroRect
Dim numPages As Integer
Dim Text As String
On Error Resume Next
Set AcrobatApp = CreateObject("AcroExch.App")
Set AcrobatDocument = CreateObject("AcroExch.AVDoc")
Set pdfDoc = CreateObject("AcroExch.PDDoc")
Set Rect = CreateObject("AcroExch.Rect")
Rect.Top = 725 'Bigger seems to be better
Rect.Left = 50 'Lower seems to be better
Rect.Right = 440 'Bigger seems to be better
Rect.bottom = 50 'Lower seems to be better




If AcrobatDocument.Open("C:\Users\42RDO\Desktop\Page 17 10+.pdf", "") Then
AcrobatApp.Show
numPages = pdfDoc.GetNumPages
For i = 1 To numPages
Text = pdfDoc.CreateTextSelect(i, Rect) 'tried to do it by putting the text in a string and then setting Cell Value to be Text but didn't work
SendKeys ("^c"), True
ActiveCell.Offset(1, 0).Select
SendKeys ("^v"), True
Next i
Else
MsgBox PDFPath & " - File not found"
Exit Sub


End If
AcrobatApp.Exit
Set AcrobatApp = Nothing
Set AcrobatDocument = Nothing




End Sub
 

Excel Facts

What is the last column in Excel?
Excel columns run from A to Z, AA to AZ, AAA to XFD. The last column is XFD.
can the pdf be word searched i.e. OCR'd. many are created from image files in which case I can't see how it would work. maybe open picture publisher and when you have the copy done, see if it pastes into PP as an image
 
Upvote 0

Forum statistics

Threads
1,216,079
Messages
6,128,690
Members
449,464
Latest member
againofsoul

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