Private Declare Function GetSystemMenu Lib "User32" (ByVal hwnd As Integer, ByVal bRevert As Long) As Integer
Private Declare Function RemoveMenu Lib "User32" (ByVal hMenu As Integer, ByVal nPosition As Integer, ByVal wFlags As Integer) As Integer
Private Declare Function DrawMenuBar Lib "User32" (ByVal hwnd As Integer) As Integer
Private Declare Function GetMenuItemCount Lib "User32" (ByVal hMenu As Integer) As Integer
Private Const MF_BYPOSITION = &H400&
Private Const MF_DISABLED = &H2&
Dim CBCtl As New ArrayList
Private Sub disableX(ByVal wnd As Excel.Application)
Dim hMenu As Integer, nCount As Integer
'得到EXCEL句柄
hMenu = GetSystemMenu(wnd.Hwnd, 0)
'获得菜单总数
nCount = GetMenuItemCount(hMenu)
'关闭菜单按钮为最后一个
Call RemoveMenu(hMenu, nCount - 1, MF_BYPOSITION Or MF_DISABLED)
'重画菜单图像
DrawMenuBar(wnd.Hwnd)
End Sub
NET程序控制EXCEL菜单代码举例
最新推荐文章于 2025-06-02 15:01:41 发布