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 2025 crash on exit after loading VBA

23 REPLIES 23
SOLVED
Reply
Message 1 of 24
capuano3d
2741 Views, 23 Replies

AutoCAD 2025 crash on exit after loading VBA

Only in AutoCAD 2025 (not Civil 3D 2025) I get a crash when I exit it everytime I load (and not necessarily run) any VBA routine. Other people that I'm in contact with are getting the same.

 

Is that an AutoCAD bug? Any thoughts?

 

Thanks

23 REPLIES 23
Message 2 of 24
norman.yuan
in reply to: capuano3d

Yes, I can reproduce the issue as you described. But I would not say it is AutoCAD 2025 crash: it is only after AutoCAD is fully closed (from Task Manager, I can see acad.exe is gone) AutoCAD's famous "Report Error" window pops up. And yes, it only occurs with vanilla AutoCAD 2025 when any VBA project is loaded. Coincidently, I also have C3D 2025 installed, which does not have the same issue. It does not hurt AutoCAD use since it only occurs after AutoCAD is closed down, but the popping up window is annoying.

 

Also, Setting AutoCAD's system variable "ReportError" to 0 does not surpress the "Report Error", like it would do to "common" crash occurred during AutoCAD session. So, I guess the "Report Error" window is called up not by AutoCAD itself, but by one of the Autodesk apps installed along with AutoCAD, and it is the fault of this "unknown-to me" app. It looks like this should be reported to Autodesk as a support case, which I might do it as soon as I can manage of bit of time, but hopefully someone else have already reported it.

 

 

Norman Yuan

Drive CAD With Code

EESignature

Message 3 of 24
norman.yuan
in reply to: capuano3d

Update - I have contacted Autodesk support: this has been a known issue for the AutoCAD development team. They will have it fix in future service pack or even next version release, just don't know when. Fortunately, this does not affect AutoCAD running, except for the annoying "Report Error" showing up after AutoCAD is shut down.

 

Norman Yuan

Drive CAD With Code

EESignature

Message 4 of 24
capuano3d
in reply to: capuano3d

Thanks for the update @norman.yuan appreciated

 

Message 5 of 24
Mr.Borges
in reply to: capuano3d

Here too. But it is a LOT more annoying: the Rubberduck VBE add-in can not be used anymore. Every time it is loaded into AutoCAD's VBE it crashes.

Message 6 of 24
DavidTosh
in reply to: capuano3d

I just upgraded to AutoCAD 2025 and after installing the VBA enabler, this behavior began. Everything seems to close correctly but after a brief delay the crash report dialog pops up.

  • I removed my VBA module from the APPLOAD list so see if there may be some compatibility from the '2024 application lurking. The same crash report pop-up happened.
  • I noticed the AutoCAD VBA enabler for 2024 hadn't been removed when I removed AutoCAD2024. I uninstalled it - and then uninstalled the 2025 VBA enabler. Launching AC2025 resulted in complaints that my VBA module couldn't be unloaded (even though I thought it had been disabled in the APPLOAD list.) Then closing AC2025 did not result in a crash report dialog.) May be because the enabler was not present, the VBA module in the APPLOAD list couldn't be removed from the list? Anyway, crash report didn't run when shutting down.
  • Re-installed VBA enabler 2025. Error report is triggered: see 777971232.
  •  

 

---
Tosh
Message 7 of 24
DavidTosh
in reply to: DavidTosh

I rely on the use of VBA routines to get my work done. Just telling me that "it does that - nothing can be done" (paraphrasing, I know.) won't cut it. This did not happen with AutoCAD 2024 (but it started misbehaving* and I thought I could just upgrade.)

 

*misbehaving = as soon as I hit the main menu file, the whole application crashed. Just started this morning after months of working normally. Autodesk has removed the "repair" option from the installer.

---
Tosh
Message 8 of 24
ed57gmc
in reply to: DavidTosh

Just to be sure, in the VBAIDE, go to Tools>References and make sure that none say "MISSING" and that you are referencing 2025 tlb's. If you are getting errors, post a screenshot.

 

I just installed 2025.1 with the VBA module and AutoCAD seemed like it was closing normally, but it still generated an error report. If you keep sending error reports, maybe they'll get it fixed sooner. Otherwise you can just close the report tool without sending. But you can still use VBA commands.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

Message 9 of 24
DavidTosh
in reply to: ed57gmc

DavidTosh_0-1724275334370.png

 

Confirming that the AutoCAD 2025 type library is referenced.

---
Tosh
Message 10 of 24
ed57gmc
in reply to: DavidTosh

Are you still able to work? and your vba routines work? If it's just the error on closing the app, just keep reporting it.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

Message 11 of 24
DavidTosh
in reply to: ed57gmc

I am able to load and run various VBE utilities that I normally use. There are times when one or more crash report dialogs are triggered while working. They are annoying but do not prevent working.

 

I've done some more troubleshooting and will report my findings in the next post.

 

There is a single action that will trigger the crash report.

---
Tosh
Message 12 of 24
ed57gmc
in reply to: DavidTosh

This bug is only related to triggering an error report on closing acad. If you are getting other crashes, it's likely due to your code.

 

BTW, It's VBA, Visual Basic for Applications. VBE is the Visual Basic Extensibility library that let's you code for the visual basic editor and it's modules.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

Message 13 of 24
DavidTosh
in reply to: DavidTosh

I've been troubleshooting my VBE project to try to determine what triggers the crash report dialog.

  • If I unload all VBE projects, the crash report does not get triggered when I close AutoCAD 2025.
  • If I enter the VBE IDE and create a trivial, do nothing code module and close AutoCAD, no crash report is triggered. (Of course, the VBE project is not reloaded next time I start AutoCAD,
  • If I enter the VBE IDE and save the trivial project, I can APPLOAD the project (I always tested with "Load Once" option) and the crash report is not triggered when I exit AutoCAD.
  • If I insert a single UserForm and save the project, the crash report is triggered when I close AutoCAD.
    • Note that simply inserting a UserForm adds a reference to "Microsoft Forms 2.0 Object Library" and checks it as being used.
    • You cannot un-check the Forms reference even if the single (only) UserForm is removed from the project.

I got to this point by adding fragments of my normal VBE project (that worked quite well under AutoCAD 2024, thank you.) and testing for the crash report dialog box being triggered on exit from AutoCAD 2025. It wasn't until I got to a declaration of a user type of a UserForm that wouldn't compile that I discovered any correlation.

 

Down the rabbit hole, I found that Microsoft Forms 2.0 ... does not appear in the "Available References:" list under Tools/References. Checking on the web, I found that in the AutoCAD VBE, as soon as you insert a UserForm, a reference to Microsoft Forms 2.0... appears. I also found out by experimentation that you can't un-check this reference-- even after removing all UserForms from the project. (I haven't found any way to rescue the project from this "corruption")

 

So, there's your hint. Can Autodesk step up and fix this? FM20.DLL is an ancient component. It includes a well-known bug in the DataObject (clipboard access) that mangles multibyte text if, and only if, more than one File Explorer window is open (by legend, this has existed since Windows 8!)

DavidTosh_0-1724353959468.png

 

---
Tosh
Message 14 of 24
DavidTosh
in reply to: DavidTosh

I will be able to live without any UI forms in my project - I don't have any I'm in love with.

 

But I would really like to be able to use clipboard access (via the DataObject type) without having to diligently close Windows File Explorer windows. 

 

Yes, I'm aware that I can create VBA code that does a windows system call to access the clipboard - I just haven't taken the time to incorporate it into my VBE project and update the subroutines that already use the DataObject. Maybe I'll get around to it now.

 

But, I upgraded to 2025 because on Monday, my AutoCAD 2024 started crashing as soon as I tried to open the main File Menu (either by mouse, keyboard ALT+F shortcut.) And, there is no longer a "repair" option in the AutoCAD installer. ;-(

 

---
Tosh
Message 15 of 24
DavidTosh
in reply to: ed57gmc

I should have said VBAIDE?

I've been coding VBA in AutoCAD since 2003.

---
Tosh
Message 16 of 24
ed57gmc
in reply to: DavidTosh


@DavidTosh wrote:

But, I upgraded to 2025 because on Monday, my AutoCAD 2024 started crashing as soon as I tried to open the main File Menu (either by mouse, keyboard ALT+F shortcut.) And, there is no longer a "repair" option in the AutoCAD installer. ;-(


I always do a clean uninstall anyway.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

Message 17 of 24
ed57gmc
in reply to: DavidTosh


@DavidTosh wrote:

I should have said VBAIDE?


Yes :beaming_face_with_smiling_eyes: In fact, that's the name of the acad command that does Alt+F11.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

Message 18 of 24
ed57gmc
in reply to: DavidTosh

First, you need to make sure that none of your code is causing any crashes. One quick troubleshooting tip is to use Debug>Compile. This will highlight any syntax bugs. Next, you need to make sure you trap any runtime errors. If you don't have any error handler in a sub or function, it will bubble up to higher level subs and be hard to locate the source. If you don't have any error handler, then acad has to handle it, which may cause a crash. I always include the following structured error handler in my subs. It handles runtime errors caused by the sub, and reports which sub the error occurred in. If there's an error, it then exits the sub gracefully.

 

Also note that in my testing of 2025, merely installing VBA caused the bug.

 

 


Public Sub SampleCommand()
    On Error GoTo Err_Control
    'Set up undo for this command
    ThisDrawing.StartUndoMark
    'do your normal process
    
    'Normal code execution exits here if there are no errors.
Exit_Here:
    ThisDrawing.EndUndoMark
    Exit Sub
     
    'Start of structured error handler
Err_Control:
    Select Case Err.Number
    Case -2147352567
        If GetAsyncKeyState(VK_ESCAPE) And &H8000 > 0 Then
            Err.Clear
            Resume Exit_Here
        ElseIf GetAsyncKeyState(VK_LBUTTON) > 0 Then
            Err.Clear
            Resume
        End If
'     Case -2145320928 'substitute with applicable error number.
'       'Add your error handler here
'       'Handle new error.
'       Err.Clear
'       Resume Exit_Here
    Case Else
        MsgBox Err.Number & " - " & Err.Description, vbCritical, "SampleCommand" 'change to the name of your command.
        Resume Exit_Here
    End Select
End Sub

 

 

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

Message 19 of 24
DavidTosh
in reply to: ed57gmc

Too Long, Didn't Read?
1. A completely empty VBA project loaded does not trigger the crash report dialog on exit.
2. The insertion of a UserForm into the project with absolutely no code does trigger the crash report on exit.
---
Tosh
Message 20 of 24
DavidTosh
in reply to: norman.yuan

See my messages in this thread as well as report number 778392028.
---
Tosh

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

Post to forums  

AutoCAD Inside the Factory


Autodesk Design & Make Report