且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

MS Access - VBA - 创建新的 Excel 工作簿

更新时间:2023-12-05 16:49:04

对于 Excel 对象,您必须始终非常具体.所以试试:

You always must be extremely specific with Excel objects. So try:

Set wbCSV = objExcel.Workbooks.Add

并小心地以相反的顺序关闭:

and careful to close in reverse order:

  wbCSV.Close acSaveNo
  Set wsCSV = Nothing
  Set wbCSV = Nothing

  wbExcel.Close acSaveNo
  Set wsExcel = Nothing
  Set wbExcel = Nothing

  objExcel.DisplayAlerts = True
  objExcel.CutCopyMode = False
  objExcel.Quit

  Set objExcel = Nothing