【发布时间】:2023-03-13 12:17:02
【问题描述】:
我正在尝试通过单击按钮从 excel vba 运行 autoitscript。
我想从 Excel 工作表运行 notepad1.au3 脚本。
我将脚本复制到与 Excel 工作表相同的目录中。
我编写了以下 vba 代码来运行脚本。一切似乎都运行良好,它准确地获取了路径文件名等。
但不是只运行脚本,而是弹出一个资源管理器窗口,要求我找到要运行的脚本。
我可以通过资源管理器窗口浏览到脚本所在的位置,然后选择脚本文件,它就会运行。
但我希望它在不打开资源管理器窗口的情况下运行。
知道问题出在哪里吗?
谢谢
VBA 代码:
Sub Autoit()
Dim AutoItPath
Dim FileName As String
Dim FileName1 As String
FileName = ThisWorkbook.Path & "\notepad1.au3"
MsgBox (FileName)
AutoItPath = "C:\Program Files (x86)\AutoIt3" & "\AutoIt3.exe "
MsgBox (AutoItPath)
FileName1 = """" & AutoItPath & """" & """" & FileName & """"
MsgBox (FileName1)
runscript = Shell(FileName1)
End Sub
【问题讨论】: