Dim xlApp As EXCEL.Application
Dim xlBook As EXCEL.Workbook
Dim filename
Dim reportini As String
filename = "\ReportModel\BatchReport.xlsm" reportini = App.Path + "\report.ini" On Error Resume Next gstrLanguage = getstring(reportini,"database","Language") Call TextIni Set xlApp = GetObject(,"Excel.Application") '判断EXCEL是否打开 If Err.Number <> 0 Then Set xlApp = CreateObject("Excel.Application") '创建EXCEL对象 xlApp.Visible = False '设置EXCEL对象不可见 End If Err.Clear If Dir(App.Path & filename) = "" Then '判断文件是否存在 MsgBox Msg_7,vbOKOnly,Title_SysMsg Exit Sub End If '判断文件是否打开 For Each xlBook In xlApp.Workbooks If xlBook.Name = Right(filename,16) Then MsgBox Msg_6,Title_SysMsg xlBook.Activate xlApp.WindowState = xlMaximized Exit Sub End If Next Set xlBook = xlApp.Workbooks.Open(App.Path & filename) '打开工件簿文件 xlBook.RunAutoMacros (xlAutoOpen) '运行EXCEL启动宏 'xlBook.RunAutoMacros (xlAutoClose) '运行EXCEL关闭宏 xlApp.Visible = True