Reputation: 203
I'm using the Forms in VBA and I was wondering if it is possible to make the tabs in my Multipages change colour when active, so that there is a better contrast with the other tabs. Here is a screenshot
Is there a way to contrast the active tab from the inactive tabs so that the user can know which tab he is using?
Or do you have any idea so that the active tab can appear better against the inactive tabs?
Upvotes: 3
Views: 7484
Reputation: 11
One method I've used is to rename the tab when activated, and include more space before and after the page name, so that the tab widens when selected for visibility, or surround with <> etc. chars: <<< TAB_NAME >>>. But lately I've considered using separate buttons to activate a page, and change the color. This saves some screenspace as the multipage itself is shorter, buttons can still look like multipage buttons being on the top left of the multipage, but then all the space to the right is free for other controls. Actually I use labels setup as command buttonds, generally smaller/less tall.
Upvotes: 1
Reputation: 9948
Approach by marking page captions by a checkmark
"Or do you have any idea so that the active tab can appear better against the inactive tabs?" -
A possible & helpful approach would be to
ChrW(&H2611)
) and to.Tag
property set at any multipage ..._Change()
event (.Tag
gets initialized via UserForm_Initialize()
firstly).As Captions may include normal blanks, I chose to add a protected blank (ChrW(&HA0)
) to the checkmark character to allow a simple Replace()
maintaining the blanks in the original page caption.
Example code in Userform
Private Sub MultiPage1_Change()
'Purpose: mark current page caption by a checkmark
With Me.MultiPage1
Dim pg As MSForms.Page
'a) de-mark old caption
Set pg = oldPage(Me.MultiPage1)
pg.Caption = Replace(pg.Caption, ChkMark, vbNullString)
'b) mark new caption & remember latest multipage value
Set pg = .Pages(.Value)
pg.Caption = ChkMark & pg.Caption
.Tag = .Value ' << remember latest page index
End With
End Sub
Help functions & UserForm_Initialize()
routine
Function oldPage(mp As MSForms.MultiPage) As MSForms.Page
'Purpose: return currently marked page in given multipage
With mp
Set oldPage = .Pages(Val(.Tag))
End With
End Function
Function ChkMark() As String
'Purpose: return ballot box with check + blank space
ChkMark = ChrW(&H2611) & ChrW(&HA0) ' ballot box with check + blank
End Function
Private Sub UserForm_Initialize()
'Purpose: mark start page & remember page index
Const startIndx As Long = 0
With Me.MultiPage1
.Pages(startIndx).Caption = ChkMark & .Pages(startIndx).Caption
.Tag = startIndx
End With
End Sub
Upvotes: 2