GetObject & CreateObject not supported

GetObject & CreateObject not supported

Anonymous
Not applicable
760 Views
6 Replies
Message 1 of 7

GetObject & CreateObject not supported

Anonymous
Not applicable
Windows XP
AutoCAD 2002
VBA

I asked this question on September 14, under a thread titled "GetObject CreateObject not supported."

I get an error message when I try to use either of these functions: "Compile error: Object library feature not supported."

The word "GetObject" or the word "CreateObject" is highlighted in the VBA IDE.

I posted my code on the September 14 thread, although the code was pretty ordinary, and no one found a problem with it that pertains to this problem.

Today I tried Joe Sutphin's suggestion. I uninstalled and re-installed AutoCAD. The problem persists.

Are there any more ideas?
0 Likes
761 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable
Well I made an error in the previous post. The portion that is highlighted is not the words I said, but the characters that precede them, that is, the portion that is highlighted is:

excelApp =

of the line

Set excelApp = ... etc.
0 Likes
Message 3 of 7

Anonymous
Not applicable
Well, a couple of items to check.

First, is Excel installed? [I know this one should be a gimme]

Second, do you have a reference set to Excel [Tools|References]

Third, does Excel appear to be working properly?

Fourth, you could attempt to instantiate an instance of Excel from something
like Word to help narrow it down.

Below is a sample of code that I know works for me.

Joe
--

Public ExcelApp As Excel.Application
Public Workbook As Excel.Workbook
Public WorkSheet As Excel.WorkSheet

Public Sub StartExcel()
On Error Resume Next
Set ExcelApp = GetObject(, "Excel.Application")
If Err Then
Err.Clear
Set ExcelApp = CreateObject("Excel.Application")
If Err Then
MsgBox "Cannot start Excel", vbCritical, "Error Starting Excel"
Unload Me
End If
End If
ExcelApp.Visible = True
Set Workbook = ExcelApp.Workbooks.Add
Set WorkSheet = ExcelApp.Worksheets(1)
End Sub

wrote in message news:4986735@discussion.autodesk.com...
Well I made an error in the previous post. The portion that is highlighted
is not the words I said, but the characters that precede them, that is, the
portion that is highlighted is:

excelApp =

of the line

Set excelApp = ... etc.
0 Likes
Message 4 of 7

Anonymous
Not applicable
Well I guess the problem has been solved. My co-worker changed the following line

Dim excelApp As Excel.Application

to

Dim excelApp

He also found it necessary, in other parts of the program that I did not post the code for, to also eliminate the type definitions for Worksheet, Workbook, and Shape. With those changes, everything's working fine.

I don't know how he thought to do that, or why it makes a difference, but I won't argue with success.

Thanks for considering my question.

Randy Richardson
Hattiesburg, MS

PS, If anyone would like to satisfy my curiosity, do you have any idea why defining those types might be a problem?

RR
0 Likes
Message 5 of 7

fxcastil
Advocate
Advocate
Randy,

You did not add a "Reference" to the excel library in your Autocad project. In the VBA editor go to Tool/Reference then
look for excel library. If you want to learn more read about late binding vs. early binding. Early binding is when you tell the VBA editor what libary you will be using before the project compiles. To test this go to the editor and type Ex the hold down the "ctrl" and "space bar " if you see excel that means you have added the reference to the excel libary (early binding). I would always recommend using early binding this way,you have acess to all the properties and methods of the library as you are writing your program.

I use the "ctrl" and "space bar " to complete typing code this way you have a quick view of properties and methods of objects you are using. Also use the View/Object browser to see the librays you have added to your project and also see what you libray can do. Sorry you went to some much troble to get your problem solved . But if you use the "ctrl" and "space bar " to help you type you will get fewer errors.

After adding the reference go back to the example Joe or I gave you in the previous posts.

Fred C
0 Likes
Message 6 of 7

Anonymous
Not applicable
This didn't solve the problem. While it solved the problem on the machine
on which the program had not worked before, the program stopped working on
all the machines on which it had previously worked.

Looking at Joe's code again, I noticed that he used "Public" where I used
"Dim," so I changed my "Dim"s to "Public". I re-defined the types. Now it
works on everyone's machine. Thanks to all those who helped and tried to
help.

-Randy

wrote in message news:4995407@discussion.autodesk.com...
Well I guess the problem has been solved. My co-worker changed the
following line

Dim excelApp As Excel.Application

to

Dim excelApp

He also found it necessary, in other parts of the program that I did not
post the code for, to also eliminate the type definitions for Worksheet,
Workbook, and Shape. With those changes, everything's working fine.

I don't know how he thought to do that, or why it makes a difference, but I
won't argue with success.

Thanks for considering my question.

Randy Richardson
Hattiesburg, MS

PS, If anyone would like to satisfy my curiosity, do you have any idea why
defining those types might be a problem?

RR
0 Likes
Message 7 of 7

fxcastil
Advocate
Advocate
See other post
0 Likes