不晓得有没有前辈遇到过这个问题,vba退出后,进程里始终有excel在运行
我写的如下的函数打开excel数据
Function newExcelApp(visible As Boolean) As Excel.Application Dim xls As Excel.Application Set xls = New Excel.Application xls.visible = visible Set newExcelApp = xls End Function
Function openExcelBook(app As Excel.Application, name As String) As Excel.workbook Dim xlbook As Excel.workbook Set xlbook = app.Workbooks.Open(name) Set openExcelBook = xlbook End Function
Function getSheet(workbook As Excel.workbook, name As String) As Excel.worksheet Dim sheets As Excel.Worksheets Dim sheet As Excel.worksheet Dim i As Integer i = 1 For i = 1 To workbook.sheets.count
If workbook.sheets.item(i).name = name Then Set getSheet = workbook.sheets.item(i) Exit Function End If Next End Function
Set dbXls = newExcelApp(False) Set dbBook = openExcelBook(dbXls, "C:\Documents and Settings\Administrator\桌面\mywork\pkpm\data.xls")
在UserForm_QueryClose事件里
dbBook.Save dbBook.Close dbXls.Quit
但是似乎不行啊
请帮忙解决一下把