|
楼主 |
发表于 2014-11-20 13:39
|
显示全部楼层
timeyh 发表于 2014-11-15 11:13
楼主,你好,你的这个东西我一直在找,但我现在找到了之后又看不懂,可否烦请在代码上加一些注解,这样, ...
Private Sub UserForm_Initialize()
Call AddNewBar‘创建菜单
Dim hbar As Long, myhwnd As Long
myhwnd = FindWindow(vbNullString, Me.Caption)’获取窗体句柄
hbar = FindWindow("MsoCommandBar", "NewBar")‘获取菜单句柄
SetParent hbar, myhwnd’将自定义菜单父窗体设置为你自己的窗体(默认的为excelAPP)
With Application.CommandBars("NewBar")'以下为调整菜单位置及设置菜单属性
.Protection = msoBarNoChangeDock
.Top = -20
.Left = -1
.Protection = 4 + 2 + 8
End With
End Sub
Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
On Error Resume Next
Application.CommandBars("NewBar").Delete‘关闭窗体时卸载自定义菜单
End Sub
|
|