PDA

View Full Version : [SOLVED:] Disbale Shift Key on workbook Open



YasserKhalil
10-11-2016, 09:57 AM
Hello everyone
I have searched but with no luck
I need to disable or prevent the user from pressing on Shift key on workbook startup ...as this prevents macros to be enabled
How to prevent the user from pressing SHIFT key on workbook startup?

mancubus
10-12-2016, 01:11 AM
http://pixcels.nl/disable-shift-key-on-open/
via Google search

YasserKhalil
10-12-2016, 02:16 PM
Thanks a lot for reply
I tried to apply the solution but could not do that. Can you attach me a file with these steps applied?

mancubus
10-13-2016, 01:19 AM
did you fully read the article?

mancubus
10-13-2016, 01:38 AM
http://www.rondebruin.nl/win/s2/win001.htm

YasserKhalil
10-13-2016, 04:27 AM
In fact I didn't get it properly. I tried to apply the steps but didn't work for me
As for last post, I don't know what the relation between custom UI and disabling the shift key .. but I feel the solution is embedded in that way
Can you explain more in steps how to do that?

snb
10-13-2016, 04:34 AM
You can't force users to use macros; and that's a very good protection of users. So you should respect that.

mancubus
10-13-2016, 05:52 AM
first download and install the Custom UI Editor.
read the manual.
Google for more.

Then review the sample files from rdb's web site.


i can't do this task on behalf of you.

mancubus
10-13-2016, 05:59 AM
@snb

in order to make users produce the desired output one may need to force them work with the same standards.

an excel file with the customized ribbon may help accomplish this.

snb
10-13-2016, 07:16 AM
In that case you don't need to disable any key(combination).

YasserKhalil
10-13-2016, 11:05 AM
Thanks a lot for great help
Now I could figure it out using CustomUIEditor and the article from first link
Thank you very much for help

mancubus
10-13-2016, 11:07 AM
@YasserKhalil

copy below code to ThisWorkbook's code module


'---------------------------------------------------------------------------------------------------
' Module : ThisWorkbook IgnoreShiftOnOpen.xlsm
' Author : Frans Bus, http://pixcels.nl/ignore-shift-key-on-open
' Date : 2013-02-26
'---------------------------------------------------------------------------------------------------

Option Explicit

Private mbMacrosEnabled As Boolean

Private Sub Workbook_Open()
mbMacrosEnabled = True
End Sub


Public Function CheckShiftOnOpen()
If Not mbMacrosEnabled Then
MsgBox "Don't press Shift on opening the workbook!", vbCritical, "Fatal error"
End If
End Function


copy below code to a standard module


'---------------------------------------------------------------------------------------------------
' Module : M1Ribbon
' Author : Frans Bus, pixcels.nl
' Date : 2013-02-26
'---------------------------------------------------------------------------------------------------

'Callback for customUI.onLoad
Sub customUIonLoad(ribbon As IRibbonUI)
Application.EnableCancelKey = xlDisabled
ThisWorkbook.CheckShiftOnOpen
End Sub



dowload the Custom UI Editor program to your PC.
open it
open your xlsm file within this program (File/Open)
from Insert click Office 2010 Custom UI Part
copy paste below code to the window on the right



<customUI xmlns="http://schemas.microsoft.com/office/2006/01/customui" onLoad="customUIonLoad" />


save and close your file.

try opening your file from within MS Excel via File/Open while holding the Shift key.

good luck!

mancubus
10-13-2016, 11:16 AM
attached is the file that i created a moment ago

YasserKhalil
10-13-2016, 11:24 AM
Thank you very much for great and awesome solution. That's exactly what I discovered after a lot of reading for both articles you provided me and you made it clear as the sun in the last two posts
Thanks a lot Mr. Mancubus for great help
Best and kind regards

mancubus
10-13-2016, 10:57 PM
you are welcome.
pls mark the thread as solved if you are sorted.