TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Humbertogo on March 07, 2006, 05:50:27 AM

Title: vl-vbaload
Post by: Humbertogo on March 07, 2006, 05:50:27 AM
When I try to use it using the vl-vbaload, it never loads:


Command: (vl-vbaload "test.dvb")'VLIDE ; error: Automation Error. Problem
in
loading DVB file


Is there more to using this function than what is in the help file?

thanks

Title: Re: vl-vbaload
Post by: Jim Yadon on March 07, 2006, 06:08:21 AM
You might try here first (http://www.theswamp.org/index.php?action=search)

I know this topic has been gone over in various incarnations and different applications in several threads.
Title: Re: vl-vbaload
Post by: Kerry on March 07, 2006, 07:13:01 AM
The "usual" cause for that message is the file not being found on the ACAD path.

Perhaps try something like this ;
Code: [Select]
(if (setq tmp (findfile "test.dvb"))
  (vl-vbaload tmp)
  ;; else
  (prompt "\n Unable to find file")
)
Title: Re: vl-vbaload
Post by: ElpanovEvgeniy on March 07, 2006, 07:28:37 AM
Code: [Select]
(if (vl-catch-all-error-p
      (vl-catch-all-apply
'vl-vbaload
(list
  (findfile "test.dvb")
) ;_  list
      ) ;_  vl-catch-all-apply
    ) ;_  vl-catch-all-error-p
  (vl-vbaload
    (list
      (getfiled "Select a VBA File \"test.dvb\"" "" "dvb" 8)
    ) ;_  list
  ) ;_  vl-vbaload
)
Title: Re: vl-vbaload
Post by: Humbertogo on March 07, 2006, 08:26:14 AM
it seen that i can not load the function from the acaddoc.lsp
when i load it from the vlisp editor or from the appload command the function
is working OK

i use

;(load "test")
 (vl-load-all "test.lsp")
but isn't load
Title: Re: vl-vbaload
Post by: kpblc on March 07, 2006, 08:37:58 AM
I think the best way is load your application through _appload window. I prefer do not change acaddoc.lsp and acad.lsp files.
Title: Re: vl-vbaload
Post by: Jürg Menzi on March 07, 2006, 09:19:46 AM
My 2¢:
(vl-vbarun "MyVba.dvb!MyModul.MySub")
Load and start in one step...
There are some known problems if the dvb is loaded on startup...
Title: Re: vl-vbaload
Post by: Humbertogo on March 07, 2006, 09:38:57 AM
Jürg

(vl-vbarun "MyVba.dvb!MyModul.MySub")

will give "Execution Error" that what i try to remove

acc ADN

;;; Issue      While executing a VBA macro from LISP, a statement that says "Execution Error"
;;;            is echoed on the command line.. My macro seems to work correctly, however, why
;;;            is the statement always there?

;;; The best way to run a VBA macro from LISP is to use the automation interface and
;;;            not the command function. Your AutoLISP code should look like the following:
Title: Re: vl-vbaload
Post by: Jürg Menzi on March 07, 2006, 10:32:27 AM
Is the dvb in a folder of the acad environment?
Or
Probably you've an error in the vba code... can you compile the project?
Title: Re: vl-vbaload
Post by: Humbertogo on March 08, 2006, 01:20:17 AM
The dvb  file is finding in the support files path
my vba project have not error
Title: Re: vl-vbaload
Post by: Jürg Menzi on March 08, 2006, 02:08:35 AM
I'm finished with my knowledge... :-(
You may post the dvb to check this behaviour...
Title: Re: vl-vbaload
Post by: Chuck Gabriel on March 08, 2006, 08:17:13 AM
You can try putting (arxload "acadvba.arx") before the line where you load your dvb.  It's not likely to help, but it's certainly worth a try.

Jurg is correct though.  We need more pieces of the puzzle before we can offer anything really helpful.
Title: Re: vl-vbaload
Post by: Humbertogo on March 08, 2006, 09:38:34 AM
This is the code what i use.

I copy the dvb file in to start in Folder and it working well (DWGPREFIX )
But when i copy the file in another folder in the support file search path
i get the err

Command: (RunVBAMacro "MsgBoxHello.dvb" "MyTestProject.MyModule.TestMacro")
; error: Automation Error. Problem in loading DVB file


(defun RunVBAMacro (dvbfilename vbaMacro / acadApplication dvbfile)
 ;; Load ActiveX   
 (vl-load-com)
  (setq acadApplication (vlax-get-acad-object))
  (setq dvbfile (findfile dvbfilename))
  (if dvbfile
   (progn (vla-LoadDVB acadApplication dvbfile) 
      (vla-RunMacro acadApplication vbaMacro)
   );progn
  )
  (if acadApplication
    (if   (null (vlax-object-released-p acadApplication))
      (progn (vlax-release-object acadApplication)
        (setq acadApplication nil)
      )
    )
  )
  (princ)
)
Title: Re: vl-vbaload
Post by: Jürg Menzi on March 08, 2006, 10:47:18 AM
That's all what you have to use:
Code: [Select]
(defun RunVBAMacro (dvbfilename vbaMacro / dvbfile)
 (vl-load-com)
 (if (setq dvbfile (findfile dvbfilename))
  (vl-vbarun (strcat dvbfile "!" vbaMacro))
 )
 (princ)
)
Call:
(RunVBAMacro "MsgBoxHello.dvb" "MyModule.TestMacro")
Note:
Don't use the project name...
And
How about the rights in this folder?
Title: Re: vl-vbaload
Post by: Humbertogo on March 08, 2006, 11:31:44 AM
The code is only working when i copy it in to the acaddoc.lsp..
but not when i load it as file (RunVBAMacro.lsp).!!!
Title: Re: vl-vbaload
Post by: Jürg Menzi on March 08, 2006, 11:42:00 AM
Hmmm...

First load:
(load "RunVBAMacro.lsp")
then run:
(RunVBAMacro "MsgBoxHello.dvb" "MyModule.TestMacro")
should work...
Title: Re: vl-vbaload
Post by: Humbertogo on March 08, 2006, 11:55:14 AM
That exact what i do.. :grazy:
Title: Re: vl-vbaload
Post by: Humbertogo on March 08, 2006, 12:24:32 PM
thanks guys

it's something wrong whit me system i just try in another an working fine :-D
Title: Re: vl-vbaload
Post by: Jürg Menzi on March 08, 2006, 12:53:02 PM
Otherwise I'm at my wits' end... :roll: