本文介绍了未知的运行时错误 VB的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个在 excel 文件中运行宏的 VB 脚本.代码运行并正确生成结果文件.
I have a VB script that runs a macro in an excel file. The code runs and produces the result file correctly.
Excel 宏本身运行良好.在 VB 代码显示未知运行时错误"后出现错误'代码 800A9C68''第 8 行''字符 2'
The Excel Macro runs fine on it's own.I get an error after the VB code saying 'Unknown runtime error' 'Code 800A9C68' 'Line 8''Char 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
推荐答案
试试下面的 VBScript:
Try the VBScript below:
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
这篇关于未知的运行时错误 VB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!