VBA "Invalid Procedure Call or Argument" Error when pasting

yits05

New Member
Joined
Jul 17, 2020
Messages
47
Office Version
  1. 2016
Platform
  1. Windows
Hello,

I have the following code which opens a PDF, copies the content into Excel, and cleans up the data a bit. However, I keep getting the "Invalid Procedure Call or Argument" error on my code which pastes the copied content -
VBA Code:
        AppActivate Application.Caption
        
        Wkb.Sheets("Sheet1").Select
        
        Wkb.Sheets("Sheet1").Cells("a1").Paste


Here is the rest of the code for context. I appreciate the help!

VBA Code:
Sub StartAdobe()


Dim AdobeApp As String
Dim AdobeFile As String
Dim StartAdobe As Long

Dim i As Long
FinalRow = Cells(Rows.Count, 1).End(xlUp).Row

    For i = 1 To FinalRow
        AdobeApp = "C:\Program Files (x86)\Adobe\Acrobat Reader DC\Reader\AcroRd32.exe"
        AdobeFile = Range("A" & i).Value
        StartAdobe = Shell("" & AdobeApp & " " & AdobeFile & "", 1)
        
        Application.Wait Now + #12:00:03 AM#
        
        SendKeys ("^a")
        
        Application.Wait Now + #12:00:01 AM#
        
        SendKeys ("^c")
        Application.Wait Now + #12:00:01 AM#
        
        SendKeys ("%{F4}")
        
        Application.Wait Now + #12:00:03 AM#
        
        Dim Wkb As Workbook
            
        Set Wkb = Workbooks("Copypdfpaste")
        
        AppActivate Application.Caption
        
        Wkb.Sheets("Sheet1").Select
        
        Wkb.Sheets("Sheet1").Cells("a1").Paste
        
        DoEvents
        
                With ActiveSheet
            .AutoFilterMode = False
            With Range("a1", Range("a" & Rows.Count).End(xlUp))
                .AutoFilter 1, "*months"
                On Error Resume Next
                .Offset(1).SpecialCells(12).EntireRow.Delete
            End With
            .AutoFilterMode = False
        End With
        
        With ActiveSheet
            .AutoFilterMode = False
            With Range("a1", Range("a" & Rows.Count).End(xlUp))
                .AutoFilter 1, "Page*"
                On Error Resume Next
                .Offset(1).SpecialCells(12).EntireRow.Delete
            End With
            .AutoFilterMode = False
        End With
        
        With ActiveSheet
            .AutoFilterMode = False
            With Range("a1", Range("a" & Rows.Count).End(xlUp))
                .AutoFilter 1, "*month"
                On Error Resume Next
                .Offset(1).SpecialCells(12).EntireRow.Delete
            End With
            .AutoFilterMode = False
        End With
        
        Worksheets("op_str").Range("A1").EntireRow.Copy Worksheets("Input").Range("B" & i)

    Next i

End Sub
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.

Michael M

Well-known Member
Joined
Oct 27, 2005
Messages
20,150
Office Version
  1. 2016
  2. 2013
  3. 2007
Platform
  1. Windows
Haven't looked at the rest of the code.....BUT this line
VBA Code:
Cells("a1").Paste
MUST be either
VBA Code:
Cells(1,1").Paste
OR
VBA Code:
Range("a1").Paste
 

yits05

New Member
Joined
Jul 17, 2020
Messages
47
Office Version
  1. 2016
Platform
  1. Windows
Haven't looked at the rest of the code.....BUT this line
VBA Code:
Cells("a1").Paste
MUST be either
VBA Code:
Cells(1,1").Paste
OR
VBA Code:
Range("a1").Paste
Hi Michael - thanks. I tried both of the alternatives but got a "object doesn't support this property or method" error for both
 

jsb1921

Board Regular
Joined
Aug 14, 2020
Messages
70
Office Version
  1. 2007
Platform
  1. Windows
  2. Web
replace the line Wkb.Sheets("Sheet1").Cells("a1").Paste with following 2 lines.
VBA Code:
Cells(1,"A").select
ActiveSheet.Paste
 
Solution

yits05

New Member
Joined
Jul 17, 2020
Messages
47
Office Version
  1. 2016
Platform
  1. Windows
replace the line Wkb.Sheets("Sheet1").Cells("a1").Paste with following 2 lines.
VBA Code:
Cells(1,"A").select
ActiveSheet.Paste
Thank you - this fixed it!
 

Watch MrExcel Video

Forum statistics

Threads
1,129,685
Messages
5,637,803
Members
416,983
Latest member
LessThanAverageUser

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
Top