That last message did not post correctly - should be trap Alt F8
PS In the first message I put the alt f8 in <> brackets, and it dident get posted
Re: That last message did not post correctly - should be trap Alt F8
David,
The short answer is "Nope". There's no way to catch the keystrokes. At least not in any way that I have found. I had an idiot boss that wanted me to stop people using the "Delete" key.
One way of hiding macros that you don't want people to run "accidentally" is to declare the sub "private" e.g.:
Private Sub menuItem_Delete1()
This will make the macro invisible to the user, but it also restricts your use of the subroutine also. If you want to use the subrouting, then you need to be in the same module or your code must be on the same object, e.g. look at any of the built-in events on the worksheet and the workbook objects, these are all private procedures e.g. the "change" event.
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
Re: That last message did not post correctly - should be trap Alt F8
Just putting in my 2 cents here, when Mark made reference to his idiot boss, it reminded me of some idiot end users (and co-workers of end users having no business even touching the file) who would also run macros at inopportune times from the Macro dialog box, which of course is possible despite the modules being protected.
To help curtail that, I prefaced some macros with an input box to force the user to enter a passcode in order to execute the macro, as such:
Dim myPassword As String
myPassword = InputBox(prompt:="Please enter the password to proceed:", _
Title:="Password is required to auto-email this file.")
If myPassword <> "YourPassword" Then
MsgBox prompt:="Click OK to return to Report.", _
Title:="Cancelled -- correct password not entered", _
Buttons:=16
Else
The rest of your code goes here.
Just a suggestion to protect yourself and the file.
Good luck.
Tom Urtis
Hi Mark and Tom,
Thanks very much to both of you for your valuable input.
I'm on a steep learning curve !!!
Have a great day
David