VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Integrating AutoCAD VBA with Microsoft Excel - Part 2

2 REPLIES 2
Reply
Message 1 of 3
mdhutchinson
279 Views, 2 Replies

Integrating AutoCAD VBA with Microsoft Excel - Part 2

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
2 REPLIES 2
Message 2 of 3
Anonymous
in reply to: mdhutchinson

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
>
Message 3 of 3
mdhutchinson
in reply to: mdhutchinson

That's it... thanks

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost