VBa Macros behave differently in different versions of AutoCAD

Discussion in 'AutoCAD' started by David Hartley, Jun 10, 2004.

  1. I'm getting strange and inconsistent results trying to use the same
    VBA-coded macros in different versions of AutCAD

    I wrote the code in AutoCAD 2002 VBA, and I tried just about every
    permutation I came accross for the macro syntax.
    These were the only forms in which I could get the macro to execute

    The code creates a toolbar and a menu macro like this:

    Toolbar Created with:
    objToolbar0.AddToolbarButton objToolbar0.Count, "WallThing", _
    "WallThing", "^C^C & -vbarun WallProject.dvb!ThisDrawing.WallThing &
    VbCr;"

    Menu Created with:
    Set objWallMenuItem = objWallMenu.AddMenuItem(0, "WallThing",
    "^C^C-vbarun;WallProject.dvb!ThisDrawing.WallThing;")
    objHipMenuItem.HelpString = "Start a new Wall"

    The first user interaction is a call to GetEntity where the prompt is "Pick
    a Wall outline"
    Here's what happens in each version



    AutoCAD 2000 Tool Bar (Works, sort of)

    Command: ^C^C Unknown command "^C^C". Press F1 for help.
    Command: & Unknown command "&". Press F1 for help.
    Command: -vbarun
    Macro name: WallProject.dvb!ThisDrawing.WallThing Pick a Wall
    Outline&
    *Invalid selection*
    Expects a point or Last
    Pick a Wall Outline

    AutoCAD 2000 Menu Macro (doesn't work)
    Command: ^C^C-vbarun;WallProject.dvb!ThisDrawing.WallThing;




    AutoCAD 2002 Menu (works)

    Command: -vbarun
    Macro name: WallProject.dvb!ThisDrawing.WallThing
    Pick a Wall Outline


    AutoCAD 2002 Toolbar (works, sort of)

    Command: ^C^C Unknown command "^C^C". Press F1 for help.
    Command: & Unknown command "&". Press F1 for help.
    Command: -vbarun
    Macro name: WallProject.dvb!ThisDrawing.WallThing Pick a Wall
    Outline&
    *Invalid selection*
    Expects a point or Last
    Pick a Wall Outline




    AutoCAD 2005 Toolbar (Works, sort of)

    Command: ^C^C Unknown command "^C^C". Press F1 for help.
    Command: & Unknown command "&". Press F1 for help.
    Command: -vbarun
    Macro name: WallProject.dvb!ThisDrawing.WallThing Pick a Wall
    Outline&
    *Invalid selection*
    Expects a point or Last
    Pick a Wall Outline

    AutoCAD 2005 Menu (doesn't work)

    Command: ^C^C-vbarun;WallProject.dvb!ThisDrawing.WallThing;
    Unknown command "^C^C-VBARUN;WallProject.DVB!THISDRAWING.WallThing;". Press
    F1 for help.


    If you've got any suggestions for something that will work in all versions,
    I would MUCH appreciate it

    Thanks,
    David
     
    David Hartley, Jun 10, 2004
    #1
  2. Well first off forget about getting it to work in all versions 2000 is vba5
    and the rest are vba6 - so no go!

    Second, you can't pass ^C you have to pass an escape character. Look under
    your Sample\VBA\VBAIDEMenu directory for the custom_menu.dvb file for
    direction.

    Also READ the help files and the WhatsNew stuff to determine all the
    changes between 2002 and 2005. Then chart your course carefully.

    -- Mike
    ___________________________
    Mike Tuersley
    CADalyst's CAD Clinic
    Rand IMAGINiT Technologies
    ___________________________
    the trick is to realize that there is no spoon...
     
    Mike Tuersley, Jun 10, 2004
    #2
  3. Well, that was interesting, but it didn't help much, because their menu
    commands are not macros, and the problem seems to be with the syntax of the
    macros
    I found a syntax that works, but I have no idea why. If someone can
    illuminate me, I'd love to hear it

    This syntax worked in 2002 and 2005 for both the toolbar and menu macros:

    Dim newMacro As String
    newMacro = Chr(3) & Chr(3) & Chr(95) & "-vbarun
    WallProject.dvb!ThisDrawing.WallThing" & vbCr

    objToolbar0.AddToolbarButton objToolbar0.Count, "WallThing", "WallThing",
    newMacro

    Beats me


    David
     
    David Hartley, Jun 10, 2004
    #3
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.