Newbie question VBALoad

Discussion in 'AutoCAD' started by BillZ, Mar 22, 2005.

  1. BillZ

    BillZ Guest

    R2005 VBA

    Hello all!

    I'm beginning to use the built in VBA in AutoCAD.
    I had followed a tutorial and created a project.
    After I opened AutoCAD, I typed in VBAIDE and the visual basic console opened. Then at the command prompt, I typed in (vl-vbaload "g:/vba/BZProjectTest.dvb") and my project loaded into the VBA console and was now visible in the console.
    Next I typed in (vl-vbarun "g:/vba/BZProjectTest.dvb!testmacro") and my dialog became visible on the AutoCAD screen and everything worked as expected. But when I look at the VBA console, I now show two BZProject1(g:\vba\bzprojecttest.dvb) in the project window.
    What am I doing wrong? And what do Ido to get rid of one of the sessions of BZProject1(g:\vba\bzprojecttest.dvb)?
    This happended yeaterday too when I did a vbaload 2 times in a row.

    Any help would be appreciated.

    TIA

    Bill
     
    BillZ, Mar 22, 2005
    #1
  2. BillZ

    James Allen Guest

    Hi Bill,

    You must mean you typed in VLIDE and the visual lisp console opened... I've
    been using the following lisp to -load and- run my vba macros.
    (vla-RunMacro (vlax-get (vlax-get-Acad-Object) 'ActiveDocument)
    "<projectname>.dvb!<modulename>.<macroname>")
    If I remember right, vl-vbarun will -load and- run your macro, but I didn't
    think it would load it again if it was already loaded.
    <not much farther along myself>
    To get rid of one, use VBAMAN and unload one.
    --
    James Allen, EIT
    Malicoat-Winslow Engineers, P.C.
    Columbia, MO


    opened. Then at the command prompt, I typed in (vl-vbaload
    "g:/vba/BZProjectTest.dvb") and my project loaded into the VBA console and
    was now visible in the console.
    dialog became visible on the AutoCAD screen and everything worked as
    expected. But when I look at the VBA console, I now show two
    BZProject1(g:\vba\bzprojecttest.dvb) in the project window.
    of BZProject1(g:\vba\bzprojecttest.dvb)?
     
    James Allen, Mar 22, 2005
    #2
  3. BillZ

    Oberer Guest

    I tried this syntax and it seems to work.
    (vl-vbarun "G:/WARE/vb/HatchUpdate.dvb!Fix_Hatch")

    (example)
    'FIX HATCH DISPLAYPROBLEMS WITH GRAVEL & CONCRETE
    (defun c:FixHatch ()
    (vl-vbarun "G:/WARE/vb/HatchUpdate.dvb!Fix_Hatch")
    )
     
    Oberer, Mar 22, 2005
    #3
  4. You must mean you typed in VLIDE and the visual lisp console opened...

    Why? He said he was using VBA. Did I miss something?
     
    Paul Richardson, Mar 22, 2005
    #4
  5. BillZ

    James Allen Guest

    Oops! <"BillZ" wrote ... at the command prompt ...> I missed that part.
    Went straight from the visual basic console to typing in lisp code and it
    didn't make much sense. So I interpreted that he was trying out his
    vba-loading lisp code on the fly in vlide. But he was trying it right at
    the command prompt, just like he said. Sorry Bill. Thanks Paul.

    James
     
    James Allen, Mar 22, 2005
    #5
  6. Oops!
    I've been there many times...;-)
     
    Paul Richardson, Mar 22, 2005
    #6
  7. BillZ

    James Allen Guest

    Bill, it looks like both vl-vbaload and vl-vbarun can load the same project
    that is already loaded. I haven't *noticed* such issues with the variation
    I posted earlier, but haven't checked for them either. You probably already
    know this, but if your code shows up when you use vbaide, then it is already
    loaded in the AutoCAD session. For working code, I think its probably best
    to always let one of the runmacro functions -load and- run your macros.
     
    James Allen, Mar 23, 2005
    #7
  8. BillZ

    BillZ Guest

    Hi JAmes,

    No I actually meant:
    "I typed in VBAIDE and the visual basic console opened."

    But anyway, thanks for the tip,I never thought about VBAMAN.

    Bill
     
    BillZ, Mar 23, 2005
    #8
  9. BillZ

    BillZ Guest

    No problem.

    But I should've read all the posts before responding.

    :^)

    Bill
     
    BillZ, Mar 23, 2005
    #9
  10. BillZ

    BillZ Guest

    Bill, it looks like both vl-vbaload and vl-vbarun can load the same project
    that is already loaded. I haven't *noticed* such issues with the variation
    I posted earlier, but haven't checked for them either. You probably already
    know this, but if your code shows up when you use vbaide, then it is already
    loaded in the AutoCAD session. For working code, I think its probably best
    to always let one of the runmacro functions -load and- run your macros.
    <<<

    It's kinda weird,

    I did the same thing this morning (just testing).
    The one I loaded using:

    (vl-vbaload "g:/vba/BZProjectTest.dvb")

    Showed up as: BZProject1 (g:\vba\BZProjectTest.dvb)

    and the one that loaded when I used.

    (vl-vbarun "g:/vba/BZProjectTest.dvb!testmacro")

    Showed up as: BZProject1 (G:\vba\BZProjectTest.dvb)

    Guess i'll just stay away from the vbaload function. :)

    Thanks


    Bill
     
    BillZ, Mar 23, 2005
    #10
  11. BillZ

    BillZ Guest

    (example)
    'FIX HATCH DISPLAYPROBLEMS WITH GRAVEL & CONCRETE
    (defun c:FixHatch ()
    (vl-vbarun "G:/WARE/vb/HatchUpdate.dvb!Fix_Hatch")
    )<<<

    Ah,

    The lights keep coming on...

    Thanks

    Bill
     
    BillZ, Mar 23, 2005
    #11
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.