PDA

View Full Version : I Need Help Vba Code Disable Key F12



etheer
09-22-2014, 12:02 PM
Hi
I Need Help Vba Code Disable Key F12

westconn1
09-22-2014, 02:33 PM
try
application.onkey {F12}, ""

note thi only works within excel

etheer
09-23-2014, 02:56 AM
i write code
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
application.onkey {F12}, ""
End Sub

but do not work
please help me

snb
09-23-2014, 03:42 AM
Why would you disable F12 ?

Szaraq
09-23-2014, 06:20 AM
Hi, there is a small mistake in westconn1's advice. There should be: "{F12}" (in quotation marks).
Anyway, it's not strange, that it doesn't work, etheer, because what you say is that, between user's save acceptation and save operation the user cannot use "F12" button (which is such a short time, that user won't even notice). I suppose you meant to block F12 button for the whole time, when this workbook remains opened. You should then insert this code in procedure Workbook_Activate. But beware, because it would also affect on other opened workbooks, so you should also add:

Private Sub Workbook_Deactivate()
Application.OnKey "{F12}"

End Sub

Hope it helped.

etheer
09-25-2014, 02:08 PM
Thank you Szaraq