Hello,
This is a bit baffling because the code has been working fine for most users and one person who has a new computer is giving me the headache.
The summary of this macro is it opens a PDF, copies and pastes it to sheet. I repeat this process for several PDF reports, open, copy, paste, close. Works fine for most people but for one person, it gets a runtime error:
It works fine the first run but when used for the second run, we get a runtime error. When I hit debug and F8 through the code, it continues correctly which make me think it doesn’t know where to paste the data.
I also tried .pastespecial format:=”Text” and it did the same thing, worked on the first pass, error on the second.
Here is a snippet of the code:
Any help is greatly appreciated
This is a bit baffling because the code has been working fine for most users and one person who has a new computer is giving me the headache.
The summary of this macro is it opens a PDF, copies and pastes it to sheet. I repeat this process for several PDF reports, open, copy, paste, close. Works fine for most people but for one person, it gets a runtime error:
VBA Code:
.Range("A" & LastRow).PasteSpecial Paste:=xlPastevalue
It works fine the first run but when used for the second run, we get a runtime error. When I hit debug and F8 through the code, it continues correctly which make me think it doesn’t know where to paste the data.
I also tried .pastespecial format:=”Text” and it did the same thing, worked on the first pass, error on the second.
Here is a snippet of the code:
VBA Code:
Set myworksheet = ActiveWorkbook.Worksheets("Interim")
Call Shell(Pathname:=shellpathname, Windowstyle:=vbNormalFocus)
‘Copy open PDF
Application.Wait Now + TimeValue("0:00:03")
SendKeys "^a"
SendKeys "^c"
'Unhide Sheet
Worksheets("Interim").Visible = True
Application.Wait Now + TimeValue("0:00:03")
Call Shell("TaskKill /F /IM Acrobat.exe", vbHide)
‘Paste PDF in next available row
With myworksheet
.Range("A1") = "A"
LastRow = myworksheet.Cells(Rows.Count, "A").End(xlUp).Row + 1
.Range("A" & LastRow).PasteSpecial Paste:=xlPastevalue
End With
Any help is greatly appreciated