I have an application that opens excel, reads some data and then closes excel. For one specific user, when the code opens Excel, Excel crashes with the message "Microsoft Excel has stopped working". Any thoughts on where to look to analyze this issue?
Here is the code I use to open / close Excel from Access. I tend to doubt the code is an issue since it works for other users and I have used it successfully for other apps.
Here is the code I use to open / close Excel from Access. I tend to doubt the code is an issue since it works for other users and I have used it successfully for other apps.
Code:
Public Sub OpenCloseExcel(xlAPP As Excel.Application, bOpen As Boolean)
'** When passed a value of True into bOpen, then this sub opens an instance of Excel
'** When passed a value of False into bOpen, then this closes an instance of Excel
Dim xlWB As Excel.Workbook
Dim xlWS As Excel.Worksheet
Dim bExcelWasOpen As Boolean
If bOpen Then
On Error Resume Next
Set xlAPP = GetObject(, "Excel.Application")
If Err.Number <> 0 Then
'Could not get instance, so create a new one
Err.Clear
Set xlAPP = CreateObject("Excel.Application")
bExcelWasOpen = False
Else ' could get open instance
bExcelWasOpen = True
'** If this is in testmode, then keep excel visible
If GetTblzAdmin("testmode") Then
xlAPP.Visible = True
Else
xlAPP.Visible = False
End If
End If
Else
xlAPP.Quit
Set xlAPP = Nothing
End If
End Sub