Disable ALT+F11

A

Alok

Could u plz tell me how to restrict/disable the user from switching to the
VBA Macro Code.

Any help would be much appreciated .
 
P

Peter

You can password-protect your macros by right-clicking on the Project, choosing "Properties", flipping to the "Protection" tab, checking "Lock project for viewing", and entering a password.
That won't disable Alt+F11, but it will hinder the user from viewing your code.

To "turn off" Alt+F11, I suppose you could bind that key combination to an empty macro:
Call Application.KeyBindings.Add(wdKeyCategoryMacro, "Module1.EmptyMacro", BuildKeyCode(wdKeyAlt, wdKeyF11))

hth,

-Peter
 
F

fumei

Check out a file called 'override.zip" from Microsoft. It has a .DOT file
showing how to disable ALL Word commands.

WARNING!!!!!!! Do not open the file unless you have the VBE OPEN. All
commands in the file are disabled, including all closing commands. In other
words, unless you have the VBE open in order to release the closing commands,
you can NOT close the file!

Sub ViewVBCode()
'Overrides Alt+F11
MsgBox "ViewVBCode"
End Sub

Pressing Alt-F11 will display the message "ViewVBCode"...the VBE will not
open.
 
P

Peter

Couldn't find "override.zip", but that sub seems marginal. Too easy to get around: just open Word, Alt+F11, then open the document whose VBA code you want to view. If the sub is in a global addin, it makes it a tiny bit harder, but you can just disable the addin, close and re-open Word. It might work better in conjunction with other methods.

-Peter
 
P

Peter

That looks like the same "override.zip" that I found via google: it obfuscates VB code so that it's more difficult to decompile.
Since it seems to apply only to compiled VB code (I couldn't inspect the file because the download "does not appear to be a valid archive"), it won't help protect VBA projects.
I'm not particularly interested in it; I was just trying to help Alok protect VBA projects.

-Peter
 
A

Alok

Thanx Peter .
Great job.


Peter said:
You can password-protect your macros by right-clicking on the Project, choosing "Properties", flipping to the "Protection" tab, checking "Lock project for viewing", and entering a password.
That won't disable Alt+F11, but it will hinder the user from viewing your code.

To "turn off" Alt+F11, I suppose you could bind that key combination to an empty macro:
Call Application.KeyBindings.Add(wdKeyCategoryMacro, "Module1.EmptyMacro", BuildKeyCode(wdKeyAlt, wdKeyF11))

hth,

-Peter
 
J

Jean-Guy Marcil

Alok was telling us:
Alok nous racontait que :
Thanx Peter .
Great job.

Just keep in mind that whatever method you choose, it will easily be
bypassed by anyone who wants to and who has access to an Internet search
engine if he/she does not really know how.

VBA code to de-allocate ALT-F11 will not work when Word security is set to
high... Then none of the code will work, but anyone can read the projects.

Setting a password is really no real security.... This is one of the easiest
password to crack...

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
F

fumei

Excuse Peter, but you state "that will not disable Alt-F11".

Hmmm, I suspect you did not actually try it. The code DOES disable Alt-F11,
it also disables Tools > Macro > Visual Basic Editor.

Sub ViewVBCode()
Msgbox "Sorry, you can't do that."
End Sub

will permanently disable opening the VBE. Alt-F11 will just give the
message. Tools > Macro > Visual Basic Editor will give the message. I would
say that effectively disables getting at code. Or perhaps there is a
different meaning to disable that I do not understand. Which is very
possible. However, the actual Word Command to open the VBE is...wait for
it...ViewVBCode.

Yes, if you are very very good, you can hack your way. However if you put
it in the ThisDocument module, I suggest you add a logic loop if you ever
want to see the code again.
 
P

Peter

fumei said:
Excuse Peter, but you state "that will not disable Alt-F11".

I did state that, but about password-protecting the project, not about ViewVBCode.
Hmmm, I suspect you did not actually try it. The code DOES disable Alt-F11,
it also disables Tools > Macro > Visual Basic Editor.

Hmmm, yes I did actually try it, and my comment was that it's too easy to get around.
Sub ViewVBCode()
Msgbox "Sorry, you can't do that."
End Sub

will permanently disable opening the VBE. Alt-F11 will just give the
message. Tools > Macro > Visual Basic Editor will give the message. I would
say that effectively disables getting at code. Or perhaps there is a
different meaning to disable that I do not understand. Which is very
possible. However, the actual Word Command to open the VBE is...wait for
it...ViewVBCode.

Why so insistent and condescending over such a minor issue?
Yes, if you are very very good, you can hack your way. However if you put
it in the ThisDocument module, I suggest you add a logic loop if you ever
want to see the code again.

(Un)fortunately, I'm not "very very good" when it comes to hacking Word, and I found it trivial to bypass.

Jean-Guy Marcil put it well:

hth,

-Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top