excel - 任何人都可以在 Excel 2010 中显示按钮 Face ID 列表

标签 excel excel-2010 vba

我想在我的 Excel 2010 文件中使用 VBA 创建服装菜单按钮,使用使用面 ID 的预定义 Excel 按钮。就我而言,我想使用“锁定”和“刷新”图标,但不知道该图标的面部 ID。谁能向我展示或指出 Excel 2010 中使用的按钮和面 ID 的列表?

最佳答案

下面的Sub BarOpen()适用于Excel 2010,很可能也适用于许多其他版本,并在“加载项”选项卡中生成一个自定义的临时工具栏,其中包含要显示的下拉菜单FaceID 为 1 .. 5020,每组 30 项。

Option Explicit

Const APP_NAME = "FaceIDs (Browser)"

' The number of icons to be displayed in a set.
Const ICON_SET = 30

Sub BarOpen()
  Dim xBar As CommandBar
  Dim xBarPop As CommandBarPopup
  Dim bCreatedNew As Boolean
  Dim n As Integer, m As Integer
  Dim k As Integer

  On Error Resume Next
  ' Try to get a reference to the 'FaceID Browser' toolbar if it exists and delete it:
  Set xBar = CommandBars(APP_NAME)
  On Error GoTo 0
  If Not xBar Is Nothing Then
    xBar.Delete
    Set xBar = Nothing
  End If

  Set xBar = CommandBars.Add(Name:=APP_NAME, Temporary:=True) ', Position:=msoBarLeft
  With xBar
    .Visible = True
    '.Width = 80
    For k = 0 To 4 ' 5 dropdowns, each for about 1000 FaceIDs
      Set xBarPop = .Controls.Add(Type:=msoControlPopup) ', Before:=1
      With xBarPop
        .BeginGroup = True
        If k = 0 Then
          .Caption = "Face IDs " & 1 + 1000 * k & " ... "
        Else
          .Caption = 1 + 1000 * k & " ... "
        End If
        n = 1
        Do
          With .Controls.Add(Type:=msoControlPopup) '34 items * 30 items = 1020 faceIDs
            .Caption = 1000 * k + n & " ... " & 1000 * k + n + ICON_SET - 1
            For m = 0 To ICON_SET - 1
              With .Controls.Add(Type:=msoControlButton) '
                .Caption = "ID=" & 1000 * k + n + m
                .FaceId = 1000 * k + n + m
              End With
            Next m
          End With
          n = n + ICON_SET
        Loop While n < 1000 ' or 1020, some overlapp
      End With
    Next k
  End With 'xBar
End Sub

关于excel - 任何人都可以在 Excel 2010 中显示按钮 Face ID 列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7382624/

相关文章:

sql-server - Excel vba xml解析性能

excel - 使用 POST 下载 Axios Excel 文件会导致文件损坏

excel - Microsoft Office Excel 2010 - IF 语句,计算日期

excel - 计算某个日期出现的次数并绘制图表

excel - VB新手。我的代码生成错误 : "expecting End With". with-end with 语句如何工作?

excel - 在 Excel 中使用两个变量显示完整的行

excel - 自动填充使用一半的核心

vba - 如何优化 Range Set 和 .Value

excel - 在我的代码中遇到问题进行多级排序

Excel VBA : Enabling Macro Settings