Dim xlApp As Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet1 As Excel.Worksheet
Dim xlsheet2 As Excel.Worksheet
Set xlApp = CreateObject("Excel.Application")
strsource = fileSet xlBook = xlApp.Workbooks.Open(strsource)
.........   '读写excel表操作
xlBook.Close(true)
xlApp.Quit
Set xlap = Nothing
Set xlBook = Nothing程序执行后按“ctrl+alt+del”发现 还是有excel进程,如何才能在读写excel后保存并关闭excel呢?谢谢

解决方案 »

  1.   

    Dim ExcelBook As Excel.Workbook
        Dim Esheets As Sheets
        Dim Esheet As Excel.Worksheet
        Dim Chart As Chart
        
        If Dir(strFilePath, vbNormal) = "" Then
            Exit Function
        End If
        
        Set ExcelBook = GetObject(strFilePath)
        Set Esheets = ExcelBook.Sheets
        If Esheets.Count = 0 Then Exit Function
        ExcelBook.Activate
        Set Esheet = Esheets(1)
        Esheet.Activate
                
        '1)将标题设置为黑体;
         Esheet.Range("A1").Font.Name = "黑体"    ExcelBook.Close
        Set ExcelBook = Nothing
        Set Esheets = Nothing
        Set Esheet = Nothing
      

  2.   

    Esheets.close
        Esheet.close
        ExcelBook.Quit
        Set ExcelBook = Nothing
        Set Esheets = Nothing
        Set Esheet = Nothing
      

  3.   

    Dim xlApp As Excel.Application
    Dim xlBook As Excel.Workbook
    Dim xlSheet1 As Excel.Worksheet
    Dim xlsheet2 As Excel.Worksheet
    Set xlApp = CreateObject("Excel.Application")
      
    set xlAP=Nothing   xlap差一个P,注意变量的名字一定得写对.检查先!!!如下应该行的:
    我的程序通过
    xlbook.Save
    xlapp.QuitSet xlsheet = Nothing
    Set xlbook = Nothing
    Set xlapp = Nothing
      

  4.   

    xlSheet1 , xlSheet2 没有 =nothing
      

  5.   

    newbook.Close False
        Set newbook = Nothing
        Ex.Quit