在UserForm1里,ImageList里储藏着待加载的4个自定义图标(不是系统的FaceId图标),如何加载到自定义的菜单工具栏上? MyPopup.Controls.Add(Type:=msoControlButton).Button.FaceId = 1023 MyBars.Controls.Add(Type:=msoControlButton) .FaceId =1023
此2句的代码要如何修改?
Sub Menu_Currency() '个性化菜单设置 On Error Resume Next Dim Popup(5) '建立新菜单(附加于默认菜单上) Dim Button As CommandBarControl Set Popup(0) = Application.CommandBars("Worksheet Menu Bar") Popup(0).Visible = True Popup(1).ImageList = ImageList1 '连接图标 Popup(1).TextAlignment = tbrTextAlignBooton '图标显示方式 Set Popup(1) = Popup(0).Controls.Add(Type:=msoControlPopup) Popup(1).Caption = "【记账凭证】 (&R)" Call MyButton(Popup(1), "凭证保存", 1023, "CreatePZ", True) Call MyButton(Popup(1), "凭证查询", 172, "FindPZ", True) Call MyButton(Popup(1), "凭证修改", 1020, "ReworkPZ", True) Call MyButton(Popup(1), "凭证删除", 644, "DeletePZ", True) Popup(1).BeginGroup = True End Sub Sub MyButton(MyPopup, Caption As String, FaceId As Integer, OnAction As String, BeginGroup As String) Set Button = MyPopup.Controls.Add(Type:=msoControlButton) Button.Caption = Space(5) & Caption Button.FaceId = FaceId Button.OnAction = OnAction Button.BeginGroup = BeginGroup End Sub Sub MyToolSet() '自定义工具栏模块 On Error Resume Next Dim MyBar As CommandBar Dim BarCoB As CommandBarComboBox Application.CommandBars("ZBSMenu").Delete Set MyBar = Application.CommandBars.Add("ZBSMenu", , False, True) MyBar.Position = msoBarTop MyBar.Protection = msoBarNoMove MyBar.Visible = True Call ZDYTool(MyBar, 1023, "保存", "CreatePZ", True, msoButtonIconAndCaption) Call ZDYTool(MyBar, 172, "查询", "FindPZ", True, msoButtonIconAndCaption) Call ZDYTool(MyBar, 1020, "修改", "ReworkPZ", True, msoButtonIconAndCaption) Call ZDYTool(MyBar, 644, "删除", "DeletePZ", True, msoButtonIconAndCaption) Call ZDYTool(MyBar, 601, "清空", "ClearPZ", True, msoButtonIconAndCaption) Set MyBar = Nothing End Sub Sub ZDYTool(MyBars, FaceId As Integer, Caption As String, OnAction As String, BeginGroup As Boolean, Style As Long) With MyBars.Controls.Add(Type:=msoControlButton) .FaceId = FaceId .Caption = Caption .OnAction = OnAction .BeginGroup = BeginGroup .Style = Style End With End Sub
xIfwCJoe.rar
(11.73 KB, 下载次数: 198)
[此贴子已经被作者于2007-7-28 15:43:18编辑过] |