i'm not sure, but try
if Err.Number <> 0
alfred
"hutch" schrieb im Newsbeitrag
news:f115856.-1@WebX.maYIadrTaRb...
> in this tutorial all seems to work except the code
> that closes excel. Oh it closes it OK but it first trigers
> an err and says that "No excel session running."
> Why does the code think that no session is running when
> it is... here is my code. I am on Windows 2000 professional,
> AutoCAD 2000 and Excel 2002
>
> Private Sub CommandButton2_Click()
> Dim excelApp As Excel.Application
> On Error Resume Next
> UserForm1.Hide
> Err.Clear
> Set excelApp = GetObject(, "Excel.Application")
> If Error <> 0 Then
> Err.Clear
> MsgBox "No excel session running.", vbExclamation
> End If
> excelApp.Quit
> UserForm1.Show
> End Sub
>