<?xml encoding=”UTF-8″>By Gopinath Taget
You might observe that Acad.lsp is reloaded when -VBARUN command is used in the S::STARTUP function to load a drawing. Is this a known behavior and is there a way to stop it from reloading? This happens even when ACADLSPASDOC variable is 0.
The reason that Acad.lsp is reloaded, with a drawing opened by a procedure in Acad.dvb (called with -VBARUN in S:STARTUP), is that AutoCAD has not finished initializing at the point in the S::STARTUP function where the command -VBARUN is called.
As a workaround, the VBASTMT command allows you to call VBA functions with arguments, from either the command line or a LISP expression. In this case, we can use (vla-sendcommand) in the (S::STARTUP) function, to call the VBA “RunMacro” method. This approach will not cause a reload of Acad.lsp
(defun-q mystartup ( )<br> (vl-load-com) ;load ActiveX objects<br> ;;replace this line: (command ".-vbarun" "MyModule.MySub") <br> ;;with the following: <br> (arxload "acadvba.arx") ;ensure Acad.dvb is loaded<br> (vla-sendcommand <br> (vla-get-activedocument (vlax-get-acad-object))<br> "vbastmtnThisDrawing.Application.RunMacro "MyModule.MySub"n"<br> )<br>)
<p>(setq s::startup (append s::startup mystartup))<br></p>

Leave a Reply to James MaedingCancel reply