PDA

View Full Version : Overriding Built-In Menus/Commands



Marcster
02-14-2007, 12:42 PM
For anyone who's interested... :dunno

You can overide the commands in Word use VBA.
For example, to overide the FileSave command:

Sub FileSave()
MsgBox "File Save disallowed."
End Sub


To stop the File > Open

Sub FileOpen
MsBox "File Open disallowed."
End Sub


For the full list of commands goto
Tools > Macro > Macros...
Macros in
Word commands

To overide the command name the Sub the same as the MacroName.

Link to Microsoft:
http://msdn2.microsoft.com/en-us/library/aa140285(office.10).aspx

Marcster.

Marcster
02-14-2007, 12:43 PM
Also,
In Word, hold down CTRL+ALT and then press +
The mouse pointer changes.
Now click on a menu item or button and hey presto!. A dialog springs up which tells you what the name of the built-in macro is called!. Look in the Commands box.

Marcster.

fumei
02-14-2007, 03:13 PM
An important note regarding the link Marcaster posted.

The download file - override.exe - unpacks override.dot.

Do NOT open this file unless you have the VBE already open and displayed.

The Close is disabled. In fact, ALL Word commands are disabled in this file. Including opening the VBE. So if the VBE is not already open, you can not go in and change the ability to Close it.

If you use the file as reference fairly often (I do), go into it and change the FileClose command (or just delete its overwride...easier), AND the open VBE command. Otherwise it is pain in the butt to work with.

Note # 2: when actioning overrides, make sure you do a Find for the Current Project, NOT just the module you think it may be in.

For example. Trapping the Print command

File > Print = Sub FilePrint()

The Print button/icon = Sub FilePrintDefault()

Two separate procedures...believe it or not.