vbastmt runs wrong sub procedure

vbastmt runs wrong sub procedure

mdhutchinson
Advisor Advisor
353 Views
1 Reply
Message 1 of 2

vbastmt runs wrong sub procedure

mdhutchinson
Advisor
Advisor
I have a suite of tools developed to embed, edit and manage related smart data in a drawing file… For one part of the suite of tools, I’ve employed a hybrid application (we’ll call it ‘A’ for discussion purposes) that uses both VBA code (in a dvb project) and a Visual Lisp file. To close down this application as well as the VBA side (dialog) forcing the dvb to unload, I am employing a line of code in the lisp file (‘A’) as follows:
[code]
(if startedfromVBA (command "vbastmt" "call basMain.cmdExitVBA"))
[/code]


I feel this is much more professional and eloquent then to leave it loaded as some have suggested and to risk its unintentional edit.

This vba statement (vbastmt) uses the VBA ‘call’ keyword to run a Public Sub Procedure (cmdExitVBA) found in the basMain code module (‘A’)

This works very well.

In this suite of tools, I have a related VBA application (we’ll call it ‘B’ for discussion purposes) which can run at the same time if the user chooses to do so. (both dialog boxes from VBA ‘A’ and ‘B’ are modeless forms employing AcFocusCtrl). This ‘B’ VBA app also unloads itself when it is closed by the user. This also works well!

The problem I am having is that if the user chooses to run both apps together in AutoCAD, when the line of code runs (in the lisp file) that is specific to ‘A’ (basMain.cmdExitVBA) for some reason doesn’t self unload, (as it does when running by itself), but instead incorrectly shuts down and unloads the VBA for ‘B’.

Now, the only similarity that I can find between the two VBA apps is that both of them have a basMain code module … but the app ‘B’ does not have a sub function called cmdExitVBA.

So why would this call close down the wrong application?
0 Likes
354 Views
1 Reply
Reply (1)
Message 2 of 2

Anonymous
Not applicable
I have seen the same problem implementing self-unloading schemes entirely within VBA. The unload statement has to be name specific. At one time I tried using VBA to return the name of the running application -- in an attempt to make a universal unload scheme -- but doing so returned the name of the other running VBA application.
0 Likes