McadApp As McadApplication/User-defined type not defined

McadApp As McadApplication/User-defined type not defined

Anonymous
Not applicable
2,051 Views
6 Replies
Message 1 of 7

McadApp As McadApplication/User-defined type not defined

Anonymous
Not applicable

Got the error


Compile error: 

 

User-defined type not defined.

 

Simple enough there, the issue is, the .dvb file was written probably around 2005, and I've been tasked with updating the mess that it is, or at least getting it to function on 2021 AutoCAD.

 

I am going to assume there are multiple user-defined types not defined, so here's what I've got on the init.

 

Option Explicit


Public McadApp As McadApplication 'The MDT5 application object
Public AcadApp As AcadApplication 'The AutoCAD application object
Public Symbb As McadSymbolBBMgr 'The Symbol manager

Public TheDrawing As AcadDocument 'The drawing to operate on

Public TheBOM As McadBOM 'The actual reference to the bom
Public TitBlockMaster As clsTitleBlock 'The Title Block
Public LayOutNumActive As Integer 'The last activelayout


'Flag for caring about loading up the bom
Public BOMCare As Boolean

Public MyBomItems As Collection
Public BOMKiller As Boolean 'Flag for seek and destroy a preexisting bom that is not named correctly


Public DWGID As Long 'DB PK
Public SupportPath As String


Public DWGSheets As Collection 'Collection of all the drawings sheets


Public OrigFileName As String

 

 

 

Also heres my current references...

0 Likes
Accepted solutions (1)
2,052 Views
6 Replies
Replies (6)
Message 2 of 7

Anonymous
Not applicable

Last addition. I DID get rid of a compile error of

Compile error: Can't find project or library

 

Which in turn gave me these missings:

 

MISSING: Autodesk MCAD Auto 2.0 Type Library

MISSING: Autodesk BRep  Auto 2.0 Type Library

MISSING: Autodesk SymBBAuto 2.0 Type Library

MISSING: AutoCAD/object DBX Common 16.0 Type Library

 

Should have put this in the original post... oops.

0 Likes
Message 3 of 7

norman.yuan
Mentor
Mentor

Assume you have AutoCAD Mechnaicl 2021 installed for updating/running the said DVB.

 

All 4 "Missing" references are out-of-date and should be removed. Then you add references to:

 

Autodesk AutoCAD Mechanical 2021 Type Library

Autodesk AutoCAD Standard Part 2021 Type Library

Autodesk GeAuto 2021 Type Library

Autodesk SymBBAuto 2021 Type Library

AutoCAD/ObjectDBX Common 24.0 Type Library

 

 

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 4 of 7

Anonymous
Not applicable

So I actually have normal Autodesk AutoCad 2021, is there a way to replace this or make this function correctly with that in mind?

 

0 Likes
Message 5 of 7

norman.yuan
Mentor
Mentor

You need to have AutoCAD Mechanical to fix/run the VBA code, if it deals with AutoCAD Mechanical functionality. Period.

 

if you do know what the VBA code did can be done with plain AutoCAD, then you can remove all the references to the Mechanical libraries and then rewrite the code to let AutoCAD to do those things. Well, I'd think it would be very difficult; otherwise why people use Mechanical at all?

 

Norman Yuan

Drive CAD With Code

EESignature

0 Likes
Message 6 of 7

Anonymous
Not applicable

Okay I now am running those on ACAD Mechanical 2021, it still throws this:

Compile error: 

 

User-defined type not defined

 

Then it highlights this line of code:

Public McadApp As McadApplication          'The MDT5 application object

 I put the ones stated in references and removed the 'missing' references as well.

0 Likes
Message 7 of 7

norman.yuan
Mentor
Mentor
Accepted solution

There are so much change from nearly 20-year-old AutoCAD Mechanical Desktop (MDT) to Acad Mechanical 2021, the old DVB file might need big or small update/modification, depending on what it is expected to do.

 

You need to examine the classes in the later Mechanical type libraries to see what are there to use. For example, instead of old "McadApplication", it is now "AcadmAuto.AcadMapplication". 

 

I suspect that it is not worth modifying the too old project. Starting a new VBA project might be easier. Again, depending on what you are to do.

Norman Yuan

Drive CAD With Code

EESignature

0 Likes