How to Disable Control Menu Items Using a WordBasic MacroLast reviewed: February 5, 1998Article ID: Q89728 |
The information in this article applies to:
SUMMARYIn Microsoft Word for Windows, there is no built-in functionality for disabling commands on the Control menus. This article provides a set of macros you can use to selectively disable some of these commands on the Word for Windows application and document Control menus. These macros give advanced WordBasic macro developers greater customization options when using the Word for Windows program.
MORE INFORMATIONFor information on using the Control menu for Microsoft Windows-based application and document windows, see pages 18-23 of the "Microsoft Windows User's Guide," version 3.1. Word for Windows adds two commands to the application Control menu:
Switch To (activates the Windows Task List) Run (runs the Windows Clipboard or Control Panel)Word for Windows also adds two commands to the document Control menu:
Next Window (switches to the next document window) Split (splits the document window into 2 panes) WordBasic Control Menu commandsThe following commands disable or enable application or document Control menu items:
SysMenu.DisableItem(x) SysMenu.EnableItem(x) SysMenu.DisableDocItem(x) SysMenu.EnableDocItem(x)The variable "x" indicates the menu item, by number. The first menu item (Restore) is 0 (zero), the second is 1, and so forth. Menu separator lines are also counted. In the Word for Windows application Control menu, the Close command is number 6.
DisableItem(x), EnableItem(x)These two commands disable and re-enable items on the Word for Windows application (or system) Control menu. Disabled items are unavailable, or dimmed. The following are the only Word for Windows application Control menu items that you can manipulate using these commands:
Menu Item Number Menu Item Name -------------------------------------- 6 Close 8 Switch To 10 Run DisableDocItem(x), EnableDocItem(x)These two commands disable and re-enable items on Word's document Control menu. Disabled items are still available; in other words, they are not dimmed. If you choose that menu item, however, no action occurs. The following are the only document Control menu items that you can manipulate using these commands:
Menu Item Number Menu Item Name -------------------------------------- 0 Restore 5 Close 7 Next Window 9 Split Create a Macro Library of These Macro CommandsBy placing these commands in a macro library, they are globally available for use in other WordBasic macros.
Using the SysMenu MacrosThe following macro disables items on the Word for Windows application, or system Control menu. After you run this macro, open the Word for Windows application Control menu and notice that the Close, Switch To and Run commands are unavailable.
Sub MAIN SysMenu.DisableItem(6) ' disable Close SysMenu.DisableItem(8) ' disable Switch To SysMenu.DisableItem(10) ' disable Run End SubThe following macro enables the previously-disabled items on the Word for Windows application Control menu. After you run this macro, open the Word for Windows application Control menu and notice that the commands are once again available.
Sub MAIN SysMenu.EnableItem(6) ' enable Close SysMenu.EnableItem(8) ' enable Switch To SysMenu.EnableItem(10) ' enable Run End SubThe following macro disables the Restore, Close, Next Window and Split items on the current Word for Windows document Control menu. After you run this macro, open the document Control menu. The disabled items appear available, but if you choose them, nothing happens.
Sub MAIN SysMenu.DisableDocItem(0) ' disable Restore SysMenu.DisableDocItem(5) ' disable Close SysMenu.DisableDocItem(7) ' disable Next Window SysMenu.DisableDocItem(9) ' disable Split End SubThe following macro enables the previously-disabled items on the document Control menu. After you run this macro, open the Word for Windows document Control menu. If you choose the re-enabled menu items, the commands function correctly.
Sub MAIN SysMenu.EnableDocItem(0) ' enable Restore SysMenu.EnableDocItem(5) ' enable Close SysMenu.EnableDocItem(7) ' enable Next Window SysMenu.EnableDocItem(9) ' enable Split End SubWARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this macro code "as is" without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose. Reference(s): "Microsoft Word for Windows User's Guide," version 2.0, pages 51, 56 "Microsoft Windows User's Guide," version 3.1, pages 18-23 "Microsoft Windows User's Guide," version 3.0, pages 28-29, 32, 60 "Microsoft Windows Software Development Kit (SDK)"
|
KBCategory: kbusage kbmacro kbhowto
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |