VBA run hangs AutoCAD

Discussion in 'AutoCAD' started by kyheulon, Sep 5, 2004.

  1. kyheulon

    kyheulon Guest

    Everyone,

    I'm currently trying to load and run a VBA with the below command in our acaddoc.lsp. When AutoCAD is launched and a new drawing "Drawing1" is opened the VBA is loaded and runs fine. Then when a drawing is opened the loading of the VBA hangs AutoCAD. The last line in the command window is "-vbarun" and nothing else happens.

    Here is what I have been able to figure out... When NOT loading the VBA and everything works fine, I launch AutoCAD and get the blank "Drawing1" drawing, then I open an existing drawing, AutoCAD closes the "Drawing1" (because nothing was done to it) and opens the desired drawing. When loading the VBA in the acaddoc.lsp, I launch AutoCAD and get the black "Drawing1" drawing, then I open an existing drawing, AutoCAD closes the "Drawing1" and opens the drawing desired and hangs. If I launch AutoCAD and manualy close the "Drawing1" drawing and then open an existing drawing it opens and runs the VBA.

    If anyone has any ideas please respond.

    Here is the command that loads and runs the VBA. And the VBA "Tester" only consists of one MsgBox line letting me know it was loaded and ran.

    (command "-vbarun" "Tester.dvb!Tester")

    Thanks,
     
    kyheulon, Sep 5, 2004
    #1
  2. Well a lot of verbiage and you didn't tell us what you want the app to do!
    To begin with, the only reason AutoCAD is closing Drawing1 is because you
    have SDI turned ON. Second, don't mess around using the acaddoc.lsp file -
    just use vba. Here are the steps:

    1. Create a blank text file and save it as ACAD.RX. In this file write one
    line:

    ACVBA.ARX [if AutoCAD 2004+] --- or ---
    ACADVBA.ARX [if <=AutoCAD 2002]

    2. Create a blank AutoCAD VBA file named ACAD.DVB

    3. In the ThisDrawing module, create a sub named AcadStartup. Anything
    within it will run once whenever AutoCAD is intially started. To have
    something run once any time a drawing is opened, add code to an event like:

    Private Sub AcadDocument_EndCommand(ByVal CommandName As String)
    If UCase(CommandName) Like "OPEN" _
    Or UCase(CommandName) Like "NEW" _
    Or UCase(CommndName) Like "QNEW" Then
    MsgBox "Opening or starting a new drawing", _
    vbOKOnly, "Event Test"
    End If
    End Sub

    Place these files somewhere within AutoCAD's search path. For a more
    detailed explanation, read my column online this month as I am discussing
    the loading aand running of vba commands automatically.

    -- Mike
    ___________________________
    Mike Tuersley
    CADalyst's CAD Clinic
    Rand IMAGINiT Technologies
    ___________________________
    the trick is to realize that there is no spoon...
     
    Mike Tuersley, Sep 6, 2004
    #2
  3. For a more detailed explanation, read my column online
    Oops! It won't be posted till the end of this week.

    -- Mike
    ___________________________
    Mike Tuersley
    CADalyst's CAD Clinic
    Rand IMAGINiT Technologies
    ___________________________
    the trick is to realize that there is no spoon...
     
    Mike Tuersley, Sep 6, 2004
    #3
  4. kyheulon

    kyheulon Guest

    Mike,

    Thanks for the information and I will be checking out your column at the end of this week. I'm just getting into using vba so I'll have to "chew" on the steps you suggested.

    We do have SDI turned OFF. Even with SDI turned OFF and you launch AutoCAD and get the standard "Drawing1" drawing, as long as you don't modify the drawing in anyway and open another drawing, AutoCAD closes "Drawing1" automatically. That's seems to be the key that causes AutoCAD to hang on the vbrun.

    I'll be looking for your column... Thanks,
     
    kyheulon, Sep 7, 2004
    #4
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.