打开已存在的EXCEL表并插入新表保存后无法关闭EXCEL进程
尝试过网上的多种方法均无法成功,何解?
Set VBEXCEL = CreateObject("Excel.Application")
      VBEXCEL.Visible = False  VBEXCEL.Workbooks.open filename:=App.Path & "\工作表.XLS"
 
   'Sheets.Add '插入表              '把此两行注释掉可以关闭EXCEL进程
'ActiveSheet.Name = "新表"  '表名  '把此两行注释掉可以关闭EXCEL进程
  
     
   VBEXCEL.DisplayAlerts = False         '关闭时不提示保存
    
  VBEXCEL.Save  VBEXCEL.Quit
  
 Set VBEXCEL = Nothing

解决方案 »

  1.   

    要释放对象才行   
        
      Set   oExcel   =   New   Excel.Application   
      If   oExcel.Workbooks.Count   =   0   Then   
            Set   oBook   =   oExcel.Workbooks.Add   
      End   If   
        .   
        .   
        .   
      oExcel.Visible   =   True   
      '释放对象   
      oexcel.quit   
      set   oexcel=nothing
      

  2.   

    Private Sub Command3_Click()
        Set ex = CreateObject("Excel.Application")
        Set wb = ex.Workbooks.Open("C:\A.XLS") '你的文件
        Set sh = wb.Sheets(1)   '第一个工作表
            ex.Sheets.Add
            ex.ActiveSheet.Name = "新表"
         ex.Visible = True
        'wb.Close SaveChanges:=True    '直接关闭不保存
        'ex.Quit
        Set ex = Nothing
        Set wb = Nothing
        Set sh = Nothing
    End Sub