Modify excel vba to extract specific data from Scan PDF to Excel.

FaizanRoshan

Board Regular
Joined
Jun 11, 2015
Messages
54
Hello,
Hi All,
I have a excel vba code that extract scan pdf first page data into excel sheet, what i want to modify code so that its allow me to extract all PDF Pages data into excel sheet rows.
Is it any possibility to done it using vba code.
Thank you for advance help.
Code:
Option Explicit

Sub GetPDFText()
' **************************************************************************
' This Sub Will Copy Text From a PDF And Paste Into Excel
' **************************************************************************


Dim varRetVal As Variant, strFullyPathedFileName As String, strCommandString As String
Dim ws As Worksheet
Dim ws1 As Worksheet


Set ws = Sheet2
On Error Resume Next
Application.DisplayAlerts = False
Worksheets("AdobeText").Delete


' **************************************************************************
' Clear Any Previous CutCopyMode
' **************************************************************************
Application.CutCopyMode = False


' *************************************
' Add A Temporary Worksheet
' *************************************
On Error Resume Next


Application.DisplayAlerts = False
Sheets("AdobeText").Delete
Application.DisplayAlerts = True


On Error GoTo 0


Sheets.Add After:=Sheets(Sheets.Count)
ActiveSheet.Name = "AdobeText"
Set ws1 = Sheets("AdobeText")
' *************************************
' Paste To The Top of the Sheet
' *************************************
Range("A1").Activate
' **************************************************************************
' For Test Purposes, Define a Path To a PDF with Text on Your System
' **************************************************************************
strFullyPathedFileName = "C:\Users\PTB\Downloads\TestFile.pdf"


' **************************************************************************
' Make Sure You Modify This To Be The Path To Your Adobe Reader
' **************************************************************************
strCommandString = "C:\Program Files (x86)\Adobe\Acrobat 11.0\Acrobat\Acrobat.exe " & strFullyPathedFileName


' **************************************************************************
' Shell Out To Adobe Reader
' **************************************************************************
varRetVal = Shell(strCommandString, 1)


' **************************************************************************
' Give It Some Time To Open
' **************************************************************************
Application.Wait Now + TimeValue("00:00:02") ' wait 2 seconds


' **************************************************************************
' Let Waiting Processes Proceed
' **************************************************************************
DoEvents


' **************************************************************************
' We Are Now In Acrobat - Select All, Copy
' **************************************************************************
SendKeys "^a"
SendKeys "^c"
SendKeys "%{F4}"
' **************************************************************************
' Give It Some Time
' **************************************************************************
Application.Wait Now + TimeValue("00:00:02") ' wait 2 seconds


' **************************************************************************
' Let Waiting Processes Proceed
' **************************************************************************
DoEvents


' **************************************************************************
' Paste To Excel's Temporary Worksheet
' **************************************************************************
AppActivate "Microsoft Excel"


ActiveSheet.Paste


Range("A:A").Select
    Selection.TextToColumns Destination:=Range("A1"), DataType:=xlDelimited, _
        TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=True, _
        Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
        :=":", FieldInfo:=Array(Array(1, 1), Array(2, 1)), TrailingMinusNumbers:=True
Range("A24").Select
     Selection.TextToColumns Destination:=Range("A24"), DataType:=xlFixedWidth, _
        OtherChar:=":", FieldInfo:=Array(Array(0, 1), Array(10, 1), Array(26, 1)), _
        TrailingMinusNumbers:=True
' **************************************************************************
' Paste To Excel Table
' **************************************************************************

 
ws.Range("C2").Value = ws1.Range("A2").Value
ws.Range("C5").Value = ws1.Range("B4").Value
ws.Range("C6").Value = ws1.Range("B5").Value
ws.Range("C8").Value = ws1.Range("B6").Value
ws.Range("C3").Value = ws1.Range("B8").Value
ws.Range("I3").Value = ws1.Range("B13").Value
ws.Range("I2").Value = ws1.Range("B14").Value
ws.Range("M3").Value = ws1.Range("B18").Value
ws.Range("M2").Value = ws1.Range("B19").Value
ws.Range("J5").Value = ws1.Range("A24").Value
ws.Range("J6").Value = ws1.Range("B24").Value
ws.Range("J7").Value = ws1.Range("C24").Value

ws.Activate

End Sub

 
Last edited:

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.

Forum statistics

Threads
1,215,575
Messages
6,125,619
Members
449,240
Latest member
lynnfromHGT

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