Dim XLS_APP As Excel.Application Dim xls As Excel.Workbook Dim referentiel As Excel.Worksheet Set XLS_APP = New Excel.Application XLS_APP.Application.ScreenUpdating = False XLS_APP.DisplayAlerts = False XLS_APP.Workbooks.Add Set xls = XLS_APP.ActiveWorkbook xls.Worksheets.Add xls.Worksheets(1).Name = "referentiel"
XLS_APP.Workbooks.Close XLS_APP.Quit Set xls = Nothing Set XLS_APP = Nothing
errHnd: XLS_APP.Workbooks.Close XLS_APP.Quit Set xls = Nothing Set XLS_APP = Nothing log.WriteLine "ECHEC lors de l'opération suivante : " & positionCode log.WriteLine "Description : " & Err.description
If blnExcelRunning Then XLS_APP.Quit End If
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionDim objExcel As Object Dim test As Boolean On Error Resume Next objExcel = GetObject(, "Excel.Application") If Err.Number = 0 Then test = True Else test = False End If blnExcelRunning = test
Set objExcel = GetObject(, "Excel.Application")
Function blnExcelRunning(ByVal MyXlhWnd As Long) As Boolean Dim objExcel As Object Dim test As Boolean, GotXlhWnd As Long On Error Resume Next Set objExcel = GetObject(, "Excel.Application") GotXlhWnd = objExcel.hWnd 'hWnd étant une propriété de l'application excel If Err.Number 0 And MyXlhWnd GotXlhWnd Then test = True Else test = False End If blnExcelRunning = test End Function
Dim XLS_APP As Excel.Application, MyXlhWnd As Long Dim xls As Excel.Workbook Dim referentiel As Excel.Worksheet Set XLS_APP = New Excel.Application MyXlhWnd = XLS_APP.hWnd XLS_APP.Application.ScreenUpdating = False XLS_APP.DisplayAlerts = False XLS_APP.Workbooks.Add ... If blnExcelRunning(MyXlhWnd) Then XLS_APP.Quit End If