Run-time error '5': invalid procedure call or argument

sara121

New Member
Joined
Jul 7, 2022
Messages
23
Office Version
  1. 365
Platform
  1. Windows
Hi Everyone and @S Oberlander,

I tried to run the VBA code shared by @S Oberlander and received Run-time error '5'. Can anyone or @S Oberlander shed some light as to how to resolve the run-time error? any Excel setting that I need to update?

Here is the link to the original post by @S Oberlander .
Here is the VBA code that @S Oberlander shared in the post
VBA Code:
Sub Extract_Data_from_PDF()
Dim App_Path As String
Dim Pdf_path As Variant
Dim shell_path As String
Dim i As Variant
Dim lastrow As Long
        
    App_Path = "C:\Program Files (x86)\Adobe\Acrobat 9.0\Acrobat\Acrobat.exe"
    Pdf_path = Application.GetOpenFilename("Pdf Files (*.pdf), *.pdf", , "Select Statements", , True)
    
    For i = LBound(Pdf_path) To UBound(Pdf_path)
    
        shell_path = App_Path & " """ & Pdf_path(i) & """"
        Call Shell(pathname:=shell_path, windowstyle:=vbNormalFocus)
        
        Application.Wait Now + TimeValue("0:00:03")
        
        SendKeys "%vpc"
        SendKeys "^a"
        SendKeys "^c"
    
        With ActiveSheet
            lastrow = .Cells(.Rows.Count, "A").End(xlUp).Row
        End With
        Range("a" & lastrow + 1).Select
        ActiveSheet.PasteSpecial Format:="Text"
    
    Next i

End Sub
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Hi,
Run-time error '5' occurs mostly when some arguments are not correct. Tell us which code line is highlighted when you get the error?
 
Upvote 0
Hi,
Run-time error '5' occurs mostly when some arguments are not correct. Tell us which code line is highlighted when you get the error?
Thanks Colo for your response. this line below was highlighted during debugging.
VBA Code:
Call Shell(pathname:=shell_path, windowstyle:=vbNormalFocus)
 
Upvote 0
is this where your acrobat program files are stored? App_Path = "C:\Program Files (x86)\Adobe\Acrobat 9.0\Acrobat\Acrobat.exe"
try removing the (x86)
 
Upvote 0
Solution
Thanks.
is this where your acrobat program files are stored? App_Path = "C:\Program Files (x86)\Adobe\Acrobat 9.0\Acrobat\Acrobat.exe"
try removing the (x86)
Thanks. @S Oberlander !! Yes. you are right, I did not update the acrobat.exe path. Its working now.

On the other note, after I run the script, the macro converted the PDF to Excel, I noticed that the all the contents are paced in column A.
Did you noticed that?
1657557869973.png

Thanks.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,173
Members
453,021
Latest member
Justyna P

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