Article ID: 192320 - Last Review: January 23, 2007 - Revision: 2.1 WD97: Disable System Menu Button and Keyboard Close CommandThis article was previously published under Q192320 On This PageSUMMARY
The following Visual Basic for Applications code will remove the Close
command from the Document System menu list and the keyboard commands
assigned to "DocClose" command. By making an item not visible, it is
removed from the menu list and unavailable to users, whether the document
is docked or windowed.
MORE INFORMATIONMicrosoft provides programming examples for illustration only, without warranty either expressed or implied. This includes, but is not limited to, the implied warranties of merchantability or fitness for a particular purpose. This article assumes that you are familiar with the programming language that is being demonstrated and with the tools that are used to create and to debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific requirements. Remove Menu ItemsTo disable the Close command or any item on the Document System menu list run the following lines of code. By making an item not visible, it is removed from the menu list and unavailable to the user, whether the document is docked or windowed on the screen.Restore Menu itemsTo restore the system menu items, you must run the following macro.NOTE: Closing and restarting Word does not restore the menu items. Disable Keyboard ShortcutTo disable the keyboard shortcut key assigned to the DocClose macro, run the following code:Assign or Reset Keyboard Shortcut KeysTo assign the default values and functionality, run one of the following Visual Basic for Applications macros:For more information about customizing Templates, from the Visual Basic Editor, click the Office Assistant, type CustomizationContext, click Search, and then click to view "CustomizationContext Property". For more information about keyboard key stroke assignment, from the Visual Basic Editor, click the Office Assistant, type KeyBindings, click Search, and then click to view "KeyBindings Collection Object". NOTE: If the Assistant is hidden, click the Office Assistant button on the Standard toolbar. If the Assistant is not able to answer your query, please see the following article in the Microsoft Knowledge Base: 176476
(http://support.microsoft.com/kb/176476/EN-US/
)
OFF: Office Assistant Not Answering Visual Basic Questions
For additional information, please see the following article in the
Microsoft Knowledge Base:
173707
(http://support.microsoft.com/kb/173707/EN-US/
)
OFF97: How to Run Sample Code from Knowledge Base Articles
| Article Translations
|

Back to the top
