我在VBA中将此代码作为宏
Sub Test()
Dim Wkb As Workbook
Set Wkb = ActiveWorkbook
notepadID = Shell("C:\Program Files\Default Company Name\TestInstaller\TestApp.exe")
SendKeys "admin", True
SendKeys "{TAB}", True
SendKeys "nothing", True
SendKeys "{ENTER}", True
SendKeys "{ENTER}", True
SendKeys "^C"
Application.Wait (Now + TimeValue("0:00:02"))
AppActivate "MicroSoft Excel"
Application.Wait (Now + TimeValue("0:00:02"))
SendKeys "^V"
Application.Wait (Now + TimeValue("0:00:02"))
End Sub
所以我要做的是将数据从数据网格复制到excel,但我只是试图复制数据网格的第一个单元格,但是当我尝试手动粘贴它时,数据是那里!我做错了什么?
答案 0 :(得分:1)
之后
SendKeys "^C"
Application.Wait (Now + TimeValue("0:00:02"))
尝试使用
ActiveCell.PasteSpecial
而不是
AppActivate "MicroSoft Excel"
Application.Wait (Now + TimeValue("0:00:02"))
SendKeys "^V"