Run VBA from toolbar

Discussion in 'AutoCAD' started by Arno van Eeuwen, Jun 15, 2004.

  1. I must be person 999 to ask this question:

    How do I load and run a DVB file from a Customized Toolbar button?
    If I manually load the DVB file and put a VBARUN command in the button it
    works.
    But how do I make the button to load the VBA project as well?

    Say I have a file C:\temp\MyVBA.DVB and I want to run public sub MyMacro.
    Any suggestions?

    TIA,
    Arno van Eeuwen
     
    Arno van Eeuwen, Jun 15, 2004
    #1
  2. Arno van Eeuwen

    Ben Rand Guest

    Actually, you're the 1000th! You win. Sorry, I've just gotten a lot of
    popups lately :).

    ^c^c(vl-vbarun "c:/path/myproject.dvb!subname");

    Note that you need to run (vl-load-com) prior to using a vl command. Most
    people put that in their startup lisp routine somewhere.

    Ben Rand
    CAD Manager
    CEntry Constructors & Engineers
     
    Ben Rand, Jun 15, 2004
    #2
  3. Thank you Ben.

    Tried it and it works in my Acad2002.(Ofcourse!)

    Now taking it one step up (or actually 2 steps back):

    How to do this in R14.01? The (VL-LOAD-COM) command doesn't work there....

    Arno
     
    Arno van Eeuwen, Jun 15, 2004
    #3
  4. Arno van Eeuwen

    Ben Rand Guest

    I'm going to have to partially defer. Acad 14 is a distant hazy memory. I
    think all the VL stuff appeared in Acad 2000(?).

    You may be able to go the

    ^c^c(command "vbaload" "c:/path/myproject.dvb")(command "vbarun" "subname");

    route. The major problem there is if the project is already loaded, you get
    this stupid message that the project is already loaded. The rest of the code
    should run, but it's annoying to keep getting that message every time you
    click a button...

    Ben
     
    Ben Rand, Jun 15, 2004
    #4
  5. Hi Ben,

    I've been successfully using vl-vbarun in R3, R2004 and R2005 Land Desktop
    without ever being aware that I needed to run (vl-load-com)

    Are you sure it's necessary ?

    --


    Laurie Comerford
    CADApps
    www.cadapps.com.au
     
    Laurie Comerford, Jun 15, 2004
    #5
  6. Arno van Eeuwen

    Jeff Mishler Guest

    The help files say this:
    These functions have names that begin with vla-, vlax-, and vlr. The vla-
    functions implement ActiveX support in AutoLISP
    Before you can use any of these functions, you need to load the AutoLISP
    extensions with the following function call:
    (vl-load-com)

    So that would mean those functions beginning with vl- (which would include
    (vl-load-com)) do NOT require it.

    Jeff
     
    Jeff Mishler, Jun 15, 2004
    #6
  7. Ben,

    I've tried your suggestion, but the VBALOAD command calls the 'Open VBA
    project' window.
    Changing to '-vbaload' creates an error so I tried to insert (command
    "filedia" "0") before the first command. Then a message occures 'An unknown
    file error occured' comes up.

    Any suggestions?

    Arno
     
    Arno van Eeuwen, Jun 16, 2004
    #7
  8. Arno van Eeuwen

    Ben Rand Guest

    Try this instead:

    (command "-vbarun" "c:/path/myproject.dvb!subname")

    If you give -vbarun the full path to the workbook!function, it will load the
    project and execute the function. If you supply just the function, it
    assumes the project is already loaded. I did not get a message trying to run
    the line a second time with the fully qualified path, but I'm using Acad
    2005. I know it used to be a problem, but it's been too long and I don't
    remember how I worked around it, prior to Acad 2000+.

    Ben
     
    Ben Rand, Jun 16, 2004
    #8
  9. Yep,

    I realize I'm going way back in time here.
    We all have stepped to 2002 a while ago, but I ran into a R14.01 user in a
    far corner of this world.
    Thanks for your support.

    Arno
     
    Arno van Eeuwen, Jun 17, 2004
    #9
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.