【发布时间】:2018-01-22 12:55:39
【问题描述】:
我有以下代码:
Sub MacroRunner()
Dim Nomefile As String, Nomefolder As String
Nomefolder = ActiveWorkbook.Path
Nomefile = Dir(Nomefolder & "\*.xlsb")
Workbooks.Open (Nomefolder & "\" & Nomefile)
ActiveWorkbook.Worksheets(2).Select
Application.Run "Nomefile!listaIdprodotto" '<-------- "nomefile" variable not returned
Application.DisplayAlerts = False
ActiveWindow.Close
End Sub
问题在由左箭头标记的行中; Excel 不返回变量值,导致自身无法找到要执行的宏。 感谢您的帮助。
【问题讨论】:
-
您的代码是否遇到任何错误消息?如果
nomefile为空白,我预计Workbooks.Open (Nomefolder & "\" & Nomefile)行会失败。