新文件中的有效Sendkeys

时间:2018-09-28 21:35:33

标签: excel vba sendkeys

我需要在excel(VBA宏)中使用sendkeys(%asccd),现在我有一个宏,该宏可以打开带有路径的文件:C:// example.xlsm,选择工作表“ Index”,在这里我需要调用“%asccd”,但是当我尝试激活此工作簿时,如果我逐步运行,则宏仅在宏内写入sccd;如果使用命令按钮运行,则仅在一个单元格内写入, 我需要将此链“ n”次运行 我如何激活最近打开的文件以使用sendkey%ascdd, 现在这是我的代码:

Sub openclose()
Dim y As String, lRow As Long, wb_source As Workbook, wb_macro As Workbook, ws_control As Worksheet, wb_a
Dim path, sName As String
Dim x As Range

   'With Application
    '.ScreenUpdating = False
    '.DisplayAlerts = False
    '.AskToUpdateLinks = False
    'End With

Set wb_macro = ActiveWorkbook


For Each x In Range("FileList")
F = x

If x = "" Then
        Exit For
    End If

Set wb_source = Workbooks.Open(Filename:=F, UpdateLinks:=0, ReadOnly:=True)
Set wb_source = ActiveWorkbook
Sheets("Index").Select
wb_source.Activate

SendKeys "%asccd"

wb_source.Close

Next x

End Sub

致谢

0 个答案:

没有答案