John, this works for Word97 (should work fine for Word 2000):Code:Option Explicit Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long Private Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long Private Const MF_BYPOSITION = &H400& Private Const MF_REMOVE = &H1000& Private Sub Form_Load() Dim hSysMenu As Long Dim nCnt As Long Dim lhwnd As Long 'Get Handle to MS Word lhwnd = FindWindow(vbNullString, "Microsoft Word - Document1") 'Get Handle to its System Menu hSysMenu = GetSystemMenu(lhwnd, False) If hSysMenu Then 'Get System menu's menu count nCnt = GetMenuItemCount(hSysMenu) If nCnt Then 'Menu count is based on 0 (0, 1, 2, 3...) RemoveMenu hSysMenu, nCnt - 1, _ MF_BYPOSITION Or MF_REMOVE 'Remove the Separator RemoveMenu hSysMenu, nCnt - 2, _ MF_BYPOSITION Or MF_REMOVE 'Force caption bar's refresh. Disabling X button DrawMenuBar Me.hwnd End If End If End Sub




Reply With Quote