PDA

View Full Version : Run macros on different occasions



dansam
02-27-2007, 08:30 AM
Hi, :hi:
What to do to run a macro which contains a massage box alert on theses different occasions:
(1) When a user opens or closes the VBE editor
(2) When a user protect or unprotect its VBA code
(3) When he clicks on the (run macro, pause macro, stop macro) buttons like ( |> , || , [] ) in VBE .


I don?t know which of these are possible or not, but if yes then please suggest me the right code. :help :help
Thanks in advance,
Dan

malik641
02-27-2007, 03:52 PM
Hey Dan,

Just curious as to why you want message box alerts to pop up with those actions?

johnske
02-27-2007, 06:13 PM
There are no events that will trigger (1) and (2), you could only check these regularly by using the "OnTime" method. However this requires a Workbook_Open event to start the clock running (example (http://xlvba.3.forumer.com/index.php?showtopic=258)) and this event can be easily disabled by holding down 'Shift' while opening the book (or so I'm told - it doesn't work on my machine) or, alternatively, by running Application.EnableEvents = False in another workbook that's been opened 1st.

For (3) you could set the OnAction property of these controls to give a message (or whatever) but the same restrictions apply to this, I'm sure you don't want to permanently disable the users VBIDE interface do you? Also, what about when the user has another workbook open at the same time? - not a good idea, you will most certainly alienate users.

From your questions I'm guessing that you're still chasing the impossible dream of 'complete Security' from hackers. The worlds best programmers realized that was a complete impossibility years ago and gave up - all that can be done is to 'raise the bar' a little bit. The only way to achieve complete security is to prohibit any access to your computer (and this also includes never ever going online) :)