VBA "Invalid Procedure Call or Argument" Error when pasting

yits05

Board Regular
Joined
Jul 17, 2020
Messages
56
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

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
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
 
Upvote 0
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
 
Upvote 0
replace the line Wkb.Sheets("Sheet1").Cells("a1").Paste with following 2 lines.
VBA Code:
Cells(1,"A").select
ActiveSheet.Paste
 
Upvote 0
Solution

Forum statistics

Threads
1,214,644
Messages
6,120,709
Members
448,983
Latest member
Joaquim_Baptista

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