Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
Option Compare Database
Option Explicit
Const cBarName = "FaceIds"
Private iFirstIcon As Integer
Public Sub ShowFaceIds()
iFirstIcon = 0
InitBar
SetBar
End Sub
Private Sub InitBar()
Dim CBR As CommandBar
Dim cmdNext As CommandBarButton
Dim cmdPrevious As CommandBarButton
Dim cmdRange As CommandBarButton
If CBRExists(cBarName) = True Then
CommandBars(cBarName).Delete
End If
Set CBR = CommandBars.Add(cBarName)
CBR.Position = msoBarFloating
Set cmdPrevious = CBR.Controls.Add
cmdPrevious.Caption = "<<Previous"
cmdPrevious.OnAction = "=FaceIdPrevious()"
cmdPrevious.Style = msoButtonCaption
cmdPrevious.Width = 80
Set cmdRange = CBR.Controls.Add
cmdRange.Style = msoButtonCaption
Set cmdNext = CBR.Controls.Add
cmdNext.Caption = "Next>>"
cmdNext.OnAction = "=FaceIdNext()"
cmdNext.Style = msoButtonCaption
cmdNext.Width = 80
CBR.Visible = True
Set CBR = Nothing
Set cmdNext = Nothing
Set cmdPrevious = Nothing
Set cmdRange = Nothing
End Sub
Private Sub SetBar()
Dim CBR As CommandBar
Dim CBC As CommandBarButton
Dim I As Integer
If iFirstIcon = 0 Then iFirstIcon = 1
Set CBR = CommandBars(cBarName)
'Remove all buttons
' For I = CBR.Controls.Count To 4 Step -1
' CBR.Controls(I).Delete
' Next
'Set new buttons
For I = iFirstIcon To iFirstIcon + 100
If CBR.Controls.Count < 104 Then
Set CBC = CBR.Controls.Add
Else
Set CBC = CBR.Controls(I - iFirstIcon + 4)
End If
CBC.Style = msoButtonIcon
CBC.Caption = I
CBC.FaceId = I
CBC.TooltipText = I
CBC.Visible = True
Next
SetRangeButton iFirstIcon & "-" & iFirstIcon + 100
CBR.Height = CBC.Height * 10
CBR.Width = CBC.Width * 10
CBR.Visible = True
Set CBC = Nothing
Set CBR = Nothing
End Sub
Private Function CBRExists(sName As String) As Boolean
Dim CBR As CommandBar
On Error Resume Next
Set CBR = CommandBars(sName)
If Err.Number <> 0 Then
Err.Clear
CBRExists = False
Else
Set CBR = Nothing
CBRExists = True
End If
Set CBR = Nothing
End Function
Public Function FaceIdNext()
iFirstIcon = iFirstIcon + 100
EnablePreviousButton True
SetBar
End Function
Public Function FaceIdPrevious()
iFirstIcon = iFirstIcon - 100
If iFirstIcon > 0 Then
SetBar
Else
EnablePreviousButton False
End If
End Function
Private Sub SetRangeButton(sCaption As String)
CommandBars(cBarName).Controls(2).Caption = sCaption
End Sub
Private Sub EnablePreviousButton(bEnable As Boolean)
CommandBars(cBarName).Controls(1).Enabled = bEnable
End Sub
Private Sub EnableNextButton(bEnable As Boolean)
CommandBars(cBarName).Controls(3).Enabled = bEnable
End Sub