Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cancel a command in VBA?

Status
Not open for further replies.

treyball3

Programmer
Jun 20, 2001
74
US
Is there a way in VBA, or even lisp for that matter, that I can cancel a command? I was thinking like on the BeginCommand event in VBA, where I could test if it was a certain command and then cancel it if it was, to keep the user from using it. Is this possible?
 
is it always the same command that you want to cancel?

if it is you could always undefine the command the the user cannot uset it at all...

for info on undefining commands follow this link --> Dan L.
freeware AutoCAD tools and standalone software, some opensource
 
Yes, it is, but I can't undefine it, because sometimes, depending on the title block, I want to actually still use it, which would cause me to redefine it, but then lose the ability to undefine it, because I undefine it when the drawing loads - If that makes any sense.
 
This snippet shows how to intercept keys. This one reacts to the ESC key. Is this the type of thing you are looking for?


Private Sub UserForm_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If KeyAscii = 27 Then
Unload Me
End If
End Sub
 
Is there a way for me to cancel it programatically without the user hitting ESC? Something like if I could send the ESC key?
 
well if it depends on the titlblock all you have to do is include a statement in the udefine lisp routine to check and see if the blockname of the desired titlblock is in the drawing...

if it is in the drawing THEN do nothing

if it is not in the drawing THEN undefine the command
Dan L.
freeware AutoCAD tools and standalone software, some opensource
 
That's a really good idea, I can't believe I didn't think of that, however, after trying that, it seems that undefine/redefine are used for the session, not per drawing, so I guess I'll have to find another way.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top