Pages

Friday, June 15, 2012

Copy Data from PDF to Excel Using Send-keys

If you want to copy the data from pdf file to Excel.



Sub method1_using_sendkey()
Dim task
' open the file
' change the path of adobe program as per your desktop
task = Shell("C:\Program Files\Adobe\Reader 9.0\Reader\AcroRd32.exe " & "C:\Documents and Settings\user\Desktop\Pdf to excel test.pdf", vbNormalFocus)

' wait 2 secs
Application.Wait Now + TimeValue("00:00:2")

'send key to select all text
SendKeys "^a", True

' wait 2 secs
Application.Wait Now + TimeValue("00:00:2")

' send key to copy
SendKeys "^c"

' wait 2 secs
Application.Wait Now + TimeValue("00:00:2")

' activate this workook and paste the data
Windows("Pdf to Excel.xlsm").Activate
Range("a2").Select
ActiveSheet.Paste

' Activate notepad
AppActivate task

' send key to close pdf file
SendKeys "^q"
MsgBox "done"
End Sub


1 comment:

  1. Check this method too

    https://groups.google.com/forum/?fromgroups#!topic/excelvbamacros/hPZsy2QyFGM

    ReplyDelete