我有一个在excel文件中运行宏的VB脚本。 代码运行并正确生成结果文件。
Excel宏运行正常。 VB代码说“未知的运行时错误”后,我收到错误消息。 '代码800A9C68' '第8行'第2章'
代码:
Dim xlApp, xlBook
Set xlApp = CreateObject("Excel.Application")
xlApp.DisplayAlerts = False
Set xlBook = xlApp.Workbooks.Open("Z:\Confidential Restricted\Weekly_HR_Employees_Macro.xlsm", False)
'msgbox("3")
xlApp.Run "Weekly_HR_Employees_Macro.Weekly_HR_Employees_Macro"
'xlbook.Save
'xlBook.Close False
'set xlBook = Nothing
xlApp.Quit
'Set xlApp = Nothing
答案 0 :(得分:2)
尝试下面的VBScript:
Option Explicit
Dim xlApp, xlBook
Set xlApp = CreateObject("Excel.Application")
set xlBook = xlApp.Workbooks.Open("Z:\Confidential Restricted\Weekly_HR_Employees_Macro.xlsm",0, False)
xlApp.Run "Weekly_HR_Employees_Macro"
xlBook.Close True
xlApp.Quit
set xlBook = Nothing
Set xlApp = Nothing