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

AutoCAD 2015 64Bit VBA error

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
2598 Views, 3 Replies

AutoCAD 2015 64Bit VBA error

Hello,

I have just installed AutoCAD 2015 64 bit version. But my VBA code which was working fine in AutoCAD2014 64 bit Shows error in AutoCAD2015.
A sample is shown below.

 

Sub test()
Dim obid As Long
Dim e As AcadEntity
obid = ThisDrawing.ModelSpace.Item(0).ObjectID32
Set e = ThisDrawing.ObjectIdToObject32(obid)
MsgBox e.Handle
End Sub


This code works fine in AutoCAD2014-64bit but Shows error in AutoCAD2015-64bit.

Any ideas on how to fix it?

Thanks

Tags (3)
3 REPLIES 3
Message 2 of 4
norman.yuan
in reply to: Anonymous

If your code contains anything like "ObjectId32" anywhere, then you need to remove "32" since AutoCAD2015.

 

ObjectId32 was used since 64 bit AutoCAD is available while its VBA remained as 32-bit (that is, there were 2 of them: ObjectId and ObjectId32). Autodesk should have removed ObjectId32 when 64-bit VBA is available for AutoCAD2014, but they did not clean that up until AutoCAD2015.

Norman Yuan

Drive CAD With Code

EESignature

Message 3 of 4
juanjogo
in reply to: norman.yuan

Hello Norman,

How can this problem be addressed if autocad 2016 VBA is called from a 32 bit Excel VBA in a 64bit system?

Im getting a system error when calling objectID in a sub that I'm writing in excel. I tried objectID32 and it is not recognized.

Message 4 of 4
norman.yuan
in reply to: juanjogo

I am not very sure how do you mean by "if autocad 2016 VBA is called from a 32 bit Excel VBA in a 64bit system". My guess would be that you have Excel VBA code that automate AutoCAD 2016 (setting reference to AutoCAD 2016 Type library). In this case (assuming your AutoCAD 2016 is 64-bit), there is no "ObjectID32" in AutoCAD COM object model. So, the your code referring "ObjectID" is correct, in theory. However, since your code is actually run in Excel's 32-bit VBA, and "ObjectID" and a 64-bit long integer, which CANNOT live in 32-bit environment, thus, your code will crash at the line where ObjectID is referred. Actually, you do not have to run to crash, in Excel VBA, if you click menu "Debug->Compile [VBA project name]", Excel itself will crash, if the code referring AutoCAD's 64-bit type data, such as ObjectID.

 

So, you may have to find a workaround, such as not referring ObjectID in your code at all (if the code's business logic can still work, of course); or you have to use 64-bit Excel, or you limit the AutoCAD logic run inside AutoCAD VBA, not in Excel VBA. As matter of fact, automating AutoCAD from outside app, such as Excel is hardly a good solution. Doing it other way around usually a much better, especially when Excel is used (or mis-used) mainly for storing data.

 

Norman Yuan

Drive CAD With Code

EESignature

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

Post to forums  

Autodesk Design & Make Report

”Boost