Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word 2000 - prevent user to close the program

Status
Not open for further replies.

Mollethewizard

IS-IT--Management
Nov 18, 2002
93
SE
I would like to prevent a user to close Word by using the upper right corner X + the close command in the File-menu. How can I programmatically do this?
 
Hello,
The procedures following can be used to disable the close button(X).
The menu-item can be deleted using 'Customize' in the right-click menu of the menubar.


Public Sub UserForm_Activate()
DisableCloseButton GetActiveWindow() 'Disable the default close button on the forms
End Sub

Sub DisableCloseButton(hWnd As Long) 'Function used to disable the close button

Dim hMenu As Long 'Define a handle to the menu
Dim menuItemCount As Long 'Define variable to hold number of menu items

hMenu = GetSystemMenu(hWnd, 0) 'Get menuhandle from application

If hMenu Then 'If menuhandle found
menuItemCount = GetMenuItemCount(hMenu) 'Count number of items on the menu
Call RemoveMenu(hMenu, menuItemCount - 1, MF_REMOVE Or MF_BYPOSITION) 'Remove items from the menu
Call DrawMenuBar(hWnd) 'Update menubar
End If


End Sub

Hope this helps
Borg
 
I'm a beginner....

Where should I put the code and how should the Call-statements look and where should i put those?

But otherwise many thanks for your concern and effort.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top