Visual Basic Customization

Visual Basic Customization

Reply
Valued Mentor
mdhutchinson
Posts: 2,313
Registered: ‎11-18-2003
Message 1 of 3 (145 Views)

Integrating AutoCAD VBA with Microsoft Excel - Part 2

145 Views, 2 Replies
10-05-2002 10:52 AM
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
*NESWADBA, Alfred
Message 2 of 3 (145 Views)

Re: Integrating AutoCAD VBA with Microsoft Excel - Part 2

10-05-2002 11:08 AM 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
>
Valued Mentor
mdhutchinson
Posts: 2,313
Registered: ‎11-18-2003
Message 3 of 3 (145 Views)

Re:

10-05-2002 11:38 AM in reply to: mdhutchinson
That's it... thanks
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.