Microsoft KB Archive/89728

{|
 * width="100%"|

How to Disable Control Menu Items Using a WordBasic Macro

 * }

Q89728

-

The information in this article applies to:


 * Microsoft Word for Windows, versions 2.0, 2.0a, 2.0a-CD, 2.0b, 2.0c, 6.0, 6.0a, 6.0c
 * Microsoft Word for Windows, version 7.0

-

SUMMARY
In 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 INFORMATION
For information on using the Control menu for Microsoft Windows-based application and document windows, see pages 18-23 of the &quot;Microsoft Windows User's Guide,&quot; 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 commands
The 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 &quot;x&quot; 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 Commands
By placing these commands in a macro library, they are globally available for use in other WordBasic macros.


 * 1) From the Tools menu, choose Macro.
 * 2) Type SysMenu in the Macro Name box and choose the Edit button.
 * 3) In the macro editing window, delete the &quot;Sub MAIN&quot; and &quot;End Sub&quot; lines and type the following macro text:
 * 4) Press CTRL+F4 to close the macro window. Choose Yes when prompted to save changes to SysMenu.

Using the SysMenu Macros
The 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 Sub The 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 Sub The 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 Sub The 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 Sub WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this macro code &quot;as is&quot; 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):

&quot;Microsoft Word for Windows User's Guide,&quot; version 2.0, pages 51, 56

&quot;Microsoft Windows User's Guide,&quot; version 3.1, pages 18-23

&quot;Microsoft Windows User's Guide,&quot; version 3.0, pages 28-29, 32, 60

&quot;Microsoft Windows Software Development Kit (SDK)&quot;

Additional query words: winword2 6.0 2.0 winword 7.0 word95 word7 word6 win31 api winapi

Keywords :

Issue type :

Technology :