Am I missing something?

Discussion in 'AutoCAD' started by Dale Levesque, Jan 5, 2004.

  1. I'm trying to call a VBA Macro in a loaded DVB file called sections.dvb. The
    module name is named Section and the sub is called g_sb_GetCoverPageData.

    (vl-load-com)
    (vl-vbarun "Sections.dvb!Section.g_sb_GetCoverPageData")

    In debug mode the codde steps over the 2nd line with no errors but the sub
    is never executed.

    Dale
     
    Dale Levesque, Jan 5, 2004
    #1
  2. Perhaps this sample will help. Note the FQN on the dvb filename, and the
    public (not private) procedure.

    'TestDVB.dvb
    'TestMod standard module
    Sub Test()
    ThisDrawing.Utility.Prompt vbCrLf & "I'm somebody now!"
    End Sub

    (defun C:Test ()
    (vl-load-com)
    (vl-VBARun "C:\\Temp\\TestDVB.dvb!TestMod.Test")
    (princ "\nI'm not a jerk!")
    (princ))


    Command: test
    _.-VBARUN
    Macro name: C:\Temp\TestDVB.dvb!TestMod.Test
    I'm somebody now!
    Command:
    I'm not a jerk!


    --
    R. Robert Bell, MCSE
    www.AcadX.com


    "Dale Levesque" <dale at dynamicwindows.com> wrote in message
    | I'm trying to call a VBA Macro in a loaded DVB file called sections.dvb.
    The
    | module name is named Section and the sub is called g_sb_GetCoverPageData.
    |
    | (vl-load-com)
    | (vl-vbarun "Sections.dvb!Section.g_sb_GetCoverPageData")
    |
    | In debug mode the codde steps over the 2nd line with no errors but the sub
    | is never executed.
    |
    | Dale
    |
    |
     
    R. Robert Bell, Jan 6, 2004
    #2
  3. "Dale Levesque" <dale at dynamicwindows.com> wrote in message
    | Once I get this running, can I assume that the vba macro will be complete
    | before the next lisp statement is evaluated?

    Nope.

    (more samples)

    Sub TestInp()
    With ThisDrawing.Utility
    .GetString True, vbCrLf & "What is your name? "
    .GetString True, vbCrLf & "What is your quest? "
    End With
    End Sub

    (defun C:Test2 ()
    (vl-load-com)
    (vl-VBARun "C:\\Temp\\TestDVB.dvb!TestMod.TestInp")
    (getstring "\nWhat is your favorite color? ")
    (princ))


    Command: test2
    _.-VBARUN
    Macro name: C:\Temp\TestDVB.dvb!TestMod.TestInp
    What is your name?
    What is your favorite color? blue

    What is your name? Sir Lancelot

    Command:
    What is your quest? To seek the Holy Grail
     
    R. Robert Bell, Jan 6, 2004
    #3
  4. If your VBA code doesn't use a form that must
    be hidden to get input from the command line,
    try starting your macro like this:

    (vla-runmacro
    (vlax-get-acad-object)
    "Sections.dvb!Section.g_sb_GetCoverPageData"
    )

    That will solve the problem with prompting,
    and LISP will wait for the VBA macro to
    finish.
     
    Tony Tanzillo, Jan 6, 2004
    #4
  5. Thanks Tony, I got a bad argument type error though after
    (vlax-get-acad-object). I managed to get everything working though using
    Roberts method.

    Best regards,

    Dale
     
    Dale Levesque, Jan 6, 2004
    #5
  6. Thanks! That works great.

    Dale
     
    Dale Levesque, Jan 6, 2004
    #6
  7. Dale - I'm afraid you're mistaken.

    "Robert's method" does not solve the problem at all.

    It works fine when the only thing you're doing is
    displaying prompts, but not when you are pausing
    for input (as per your example). In that case, the
    LISP code after the call to (vl-vbarun) executes
    before the VBA macro's prompts are issued.

    If you got an error with (vla-runmacro) you must
    have done something wrong, because it works just
    fine here.
     
    Tony Tanzillo, Jan 6, 2004
    #7
  8. Actually I don't have to prompt for user input. I think that was Robert's
    example. I tried vla-RunMacro with a fully qualified path and it worked
    great.

    Thanks again.

    Dale
     
    Dale Levesque, Jan 6, 2004
    #8
  9. Dale Levesque

    Mark Propst Guest

    fwiw, as Tony's post implied and a quick test confirmed, the path doesn't
    need to be full, (if it's on the searchpath.)
     
    Mark Propst, Jan 6, 2004
    #9
  10. Correct. I'm sorry I implied that. I thought that Dale's trouble might be
    related to his dvb not being located in the search path.


    --
    R. Robert Bell, MCSE
    www.AcadX.com


    "Mark Propst" <notmark-at-atreng-dot-com> wrote in message
    | fwiw, as Tony's post implied and a quick test confirmed, the path doesn't
    | need to be full, (if it's on the searchpath.)
    |
    | "Dale Levesque" <dale at dynamicwindows.com> wrote in message
    | | > Actually I don't have to prompt for user input. I think that was
    Robert's
    | > example. I tried vla-RunMacro with a fully qualified path and it worked
    | > great.
    | >
    | > Thanks again.
    | >
    | > Dale
    | >
    |
    |
     
    R. Robert Bell, Jan 6, 2004
    #10
  11. That kind of threw me. I assumed that if the said DVB was loaded it would be
    found. Thanks for pointing that out.

    Dale
     
    Dale Levesque, Jan 6, 2004
    #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.