我在ACCESS中打开了一个EXCEL表,用以下代码来关闭EXCEL,但好象没能结束EXCEL进程。帮忙看看,谢谢! Book.Save '存盘EXCEL表 Book.Close '关闭EXCEL表 Set ws = Nothing 'ws是工作表 Set Book = Nothing 'book是工作簿 Set ExApp =Nothing '
这是EXCEL应用的问题,不是ACCESS应用的问题。请看一看: Function biaoti() Dim ExApp As Excel.Application Dim Book AsExcel.Workbook Dim ws As Worksheet Dim j As Integer '确定行号 Dim i AsInteger '确定行号 Dim k As Integer '循环用 Dim rowI As Integer '确定行记录数 Dim m As Integer Dim n As Integer DoCmd.SetWarnings False Set ExApp= New Excel.Application Set Book = ExApp.Workbooks.Open("C:\Program Files\日线.xls")Set ws = Book.Worksheets("日线") ws.Cells(1, 26) = "记录数" m = 5 n =10 i = m + 1 j = n + 1 ws.Cells(2, 26).Formula = "=COUNT(A:A)+1" '获得行记录数,用确定复制公式的限位 rowI = ws.Cells(2, 26) '确定行记录数ws.Range("W" & i & "").Select ws.Cells(m + 1,23).Formula = "=sum(G2:" & "G" & i &")/" & m & "" Selection.AutoFillDestination:=ws.Range("W" & i & " : W" & rowI& "") ws.Range("X" & j & "").Selectws.Cells(n + 1, 24).Formula = "=sum(G2:" & "G" & j& ")/" & n & "" Selection.AutoFillDestination:=ws.Range("X" & j & " : X" & rowI& "") Book.Save Book.Close Set ws = Nothing Set Book = NothingExApp.Quit Set ExApp = Nothing End Function
共 1 个关于本帖的回复 最后回复于 2013-7-11 10:55