The problem you're having unloading from Lisp is that it's running the command and immediately running the next, without waiting to see if it's complete. Like shelling to a DOS command, or something.
Looping through with a timer, hoping to catch the end, is just going to tie up your system; because now the loop you're running is slowing down the *other* command you're trying to run. It's not needed.
Just have a "loader" .dvb routine. Have this .dvb file loaded by lisp at startup, if you want; the loader .dvb will be a small footprint, having nothing but a few lines of VBA code to 1) load a DVB file 2) execute a specific Subroutine in a specific module, and 3) unload the DVB file when the process is complete. There will be no simultaneosly running code. There will be no Do:Loop putting a brake on your system. Remember, just like calling code in a .BAS module from a form, the calling routine will be ON HOLD until the new routine is finished.
In addition, keeping the VBA IDE free from code allows for faster execution, easier editing, etc , etc.
Heres a sample of what I use:
;-----------------------------------------------------------
; Utils.lsp
; loader routine for "Loader.dvb"
; load "launcher" DVB file
(setvar "cmdecho" 0)
(vl-vbaload "Y:/MRW_Palette/Mrw_Utils.dvb")
(setvar "cmdecho" 1)
(princ)
; ------------------------------
; define launcher for Excel Reports
(defun c:xlr ()
; call excel reports vba module
(setvar "cmdecho" 0)
(VL-VBARUN "XL_Reports")
(setvar "cmdecho" 1)
(princ)
)
; ------------------------------
; define launcher for generating Views
(defun c:mvw ()
; call Make Views vba module
(setvar "cmdecho" 0)
(VL-VBARUN "MVW")
(setvar "cmdecho" 1)
(princ)
)
; ------------------------------
;-----------------------------------------------------------
' and in my "Loader.dvb" file (Y:/MRW_Palette/Mrw_Utils.dvb)
' i have something like the following 2 subs:
Sub XL_Reports()
' Load a sample VBA project DVB file
LoadDVB "c:\test\excel_reports.dvb"
' Run the referenced macro
RunMacro "modMrwReport.Report_Init"
' Unload the VBA project DVB file now.
UnloadDVB "c:\test\excel_reports.dvb"
End Sub
Sub MVW()
' Load a sample VBA project DVB file
LoadDVB "c:\xyz\Make2d\Make_views.dvb"
' Run the referenced macro
RunMacro "modMain.Read_Solids"
' Unload the VBA project DVB file now.
UnloadDVB "c:\xyz\Make2d\Make_views.dvb"
End Sub
'--------------------------