如何在VB中正确将调用的Excel进程关闭?

twodollars 2002-11-13 12:17:29
我在程序中调用了Excel进行数据处理,但是数据处理后无法将调用的Excel关闭,这是为什么?
Dim OutPutExcel As Object
Dim MainBook As Excel.Workbook

Const ClassObject = "Excel.Application"
Set OutPutExcel = CreateObject(ClassObject)

Set MainBook = OutPutExcel.Workbooks.Open(App.Path & "\" & "ExportWizard.xls")

......

MainBook.SaveAs SaveFile
MainBook.Close
OutPutExcel.Quit
Set OutPutExcel = Nothing
Set MainBook = Nothing
Set MainSheet = Nothing
...全文
114 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
of123 2002-11-13
  • 打赏
  • 举报
回复
Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook

' Open the destination Excel workbook.
Set xlApp = New Excel.Application
Set xlBook = xlApp.Workbooks.Open("D:\Book1.xls")
......

' Clean up everything.
xlBook.Save
xlBook.Close False
xlApp.Quit
Set xlBook = Nothing
Set xlApp = Nothing

7,785

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧