Results 1 to 9 of 9

Thread: How to make excel vba crash proof?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #9
    VBAX Regular
    Joined
    Sep 2016
    Posts
    8
    Location
    Oh, i guess that's because of the pasting.
    It's two lines in my code.

    btw, i found this
    Sub Main()    
    Dim ACAD As AcadApplication 'Create ACAD variable of type Acad Application
    
        On Error Resume Next 'This tells VBA to ignore errors
        Set ACAD = GetObject(, "AutoCAD.Application") 'Get a running instance of the class AutoCAD.Application
        On Error GoTo 0 'This tells VBA to go back to NOT ignoring errors
    
        If ACAD Is Nothing Then 'Check to see if the above worked
            Set ACAD = New AcadApplication 'Set the ACAD variable to equal a new instance of AutoCAD
            ACAD.Visible = True 'Once loaded, set AutoCAD® to be visible
        End If
    
        ACAD.ActiveDocument.Utility.Prompt "Hello from Excel!" 'Print a message to the AutoCAD® command line 
    End Sub
    and using the code to open the cad.
    and by activating the autocad library in the vba, It's not crashing anymore now

    Thanks
    Last edited by SamT; 09-27-2016 at 02:39 PM. Reason: Removed Font and ColorTags. Added CrLfs and white space

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •