Option Explicit
Const APP_NAME = "FaceID Browser"
' The number of icons to be displayed in a set.
Const ICON_SET = 100
Public lngSetMarker As Long
Private Sub BarOpen()
Dim xBar As CommandBar
Dim xBarButton As CommandBarButton
Dim bCreatedNew As Boolean
' Read the value in the registry
lngSetMarker = GetSetting(APP_NAME, "Preferences", "LastSet", 1)
On Error Resume Next
' Try to get a reference to the 'FaceID Browser' toolbar if
' it exists.
Set xBar = CommandBars(APP_NAME)
' If it doesn't exist then create a new toolbar
If xBar Is Nothing Then
Set xBar = CommandBars.Add(Name:=APP_NAME, Temporary:=False)
bCreatedNew = True
End If
Set xBarButton = xBar.FindControl(Tag:="msoTagAboutMe")
If xBarButton Is Nothing Then
Set xBarButton = xBar.Controls.Add(Type:=msoControlButton, Before:=1)
With xBarButton
.Caption = "About..."
.Style = msoButtonCaption
Select Case Application.Name
Case "Microsoft PowerPoint"
.OnAction = "IDBrowse.ppa!About"
Case "Microsoft Excel"
.OnAction = "IDBrowse.xla!About"
Case "Microsoft Word"
.OnAction = "IDBrowse.dot!About"
End Select
.DescriptionText = "Information about the author"
.Tag = "msoTagAboutMe"
End With
End If
Set xBarButton = xBar.FindControl(Tag:="msoTagPrev100")
If xBarButton Is Nothing Then
Set xBarButton = xBar.Controls.Add(Type:=msoControlButton, Before:=2)
End If
With xBarButton
.BeginGroup = True
.Style = msoButtonCaption
.TooltipText = "Previous 100 FaceId values"
.Caption = "« Previous "
Select Case Application.Name
Case "Microsoft PowerPoint"
.OnAction = "IDBrowse.ppa!PrevID"
Case "Microsoft Excel"
.OnAction = "IDBrowse.xla!PrevID"
Case "Microsoft Word"
.OnAction = "IDBrowse.dot!PrevID"
End Select
.DescriptionText = "Displays icons associated with previous 100 face ids"
.Tag = "msoTagPrev100"
.Enabled = False
End With
Set xBarButton = xBar.FindControl(Tag:="msoTagNext100")
If xBarButton Is Nothing Then
Set xBarButton = xBar.Controls.Add(Type:=msoControlButton, Before:=3)
End If
With xBarButton
.Style = msoButtonCaption
.Caption = " Next »"
.TooltipText = "Next 100 FaceId values "
Select Case Application.Name
Case "Microsoft PowerPoint"
.OnAction = "IDBrowse.ppa!NextID"
Case "Microsoft Excel"
.OnAction = "IDBrowse.xla!NextID"
Case "Microsoft Word"
.OnAction = "IDBrowse.dot!NextID"
End Select
.DescriptionText = "Displays icons associated with next 100 face ids"
.Tag = "msoTagNext100"
End With
With xBar
.FindControl(Tag:="msoTagNext100").Execute
If bCreatedNew Then
.Width = 246
.Top = 100
.Left = 100
End If
.Visible = GetSetting(APP_NAME, "Preferences", "Visible", True)
End With
End Sub
Private Sub BarClose()
On Error Resume Next
' Save the state of the toolbar and the currrent active set to the registry
SaveSetting APP_NAME, "Preferences", "Visible", Val(CommandBars(APP_NAME).Visible)
SaveSetting APP_NAME, "Preferences", "LastSet", lngSetMarker - ICON_SET
CommandBars(APP_NAME).Visible = False
End Sub
|