M
Mark Andrews
Anyone know a way to get text on a commandbar (used as a toolbar)?
Below is the code I use and just trying to get:
"Monday, February 16, 2009" to show on the toolbar.
I added this code and got text but it is also a menu (I just want the text).
Set CBC = CB.Controls.Add(Type:=msoControlPopup)
CBC.Caption = Format(Now(), "Long Date")
CBC.Tag = Format(Now(), "Long Date")
CBC.OnAction = ""
Thanks in advance,
Mark
Public Function CreateToolbar()
On Error GoTo Err_CreateToolbar
'Creates the toolbar "RPTToolbar"
Dim MenuName As String
Dim CBS As Office.CommandBars
Dim CB As CommandBar
Dim CBC As CommandBarControl
Dim CBB As CommandBarButton
Dim CBP As CommandBarPopup
MenuName = "RPTToolbar"
'delete menu if it already exists
If fIsCreated(MenuName) Then
Application.CommandBars(MenuName).Delete
End If
'create menu and appropriate commandbuttons
Set CB = Application.CommandBars.Add(MenuName, msoBarTop, False, False)
CB.Visible = True
CB.Protection = msoBarNoMove
'*** Items off File Menu
Set CBB = CB.Controls.Add(msoControlButton, , , , True)
CBB.Caption = "Customers..."
CBB.Tag = "Customers..."
CBB.FaceId = 1099
CBB.OnAction = "=OpenForm(""frmCustomerList"")"
Set CBB = CB.Controls.Add(msoControlButton, , , , True)
CBB.Caption = "Resources..."
CBB.Tag = "Resourcess..."
CBB.FaceId = 607
CBB.OnAction = "=OpenForm(""frmResourceList"")"
'*** Items off View Menu
Set CBB = CB.Controls.Add(msoControlButton, , , , True)
CBB.Caption = "Find Avalable Time..."
CBB.Tag = "Find Avalable Time..."
CBB.FaceId = 183
CBB.OnAction = ""
CBB.BeginGroup = True
Set CBB = CB.Controls.Add(msoControlButton, , , , True)
CBB.Caption = "Search for Appointment..."
CBB.Tag = "Search for Appointment..."
CBB.FaceId = 46
CBB.OnAction = ""
'*** Items off Tools Menu
Set CBB = CB.Controls.Add(msoControlButton, , , , True)
CBB.Caption = "Email..."
CBB.Tag = "Email..."
CBB.FaceId = 24
CBB.OnAction = ""
CBB.BeginGroup = True
Set CBB = CB.Controls.Add(msoControlButton, , , , True)
CBB.Caption = "Letters..."
CBB.Tag = "Letters..."
CBB.FaceId = 42
CBB.OnAction = ""
'*** Misc Items
Set CBC = CB.Controls.Add(Type:=msoControlDropdown)
CBC.Caption = "Timescale"
CBC.Style = msoButtonAutomatic
CBC.AddItem "10 Minutes"
CBC.AddItem "15 Minutes"
CBC.AddItem "30 Minutes"
CBC.AddItem "60 Minutes"
CBC.ListIndex = 1
Set CBC = CB.Controls.Add(Type:=msoControlPopup)
CBC.Caption = Format(Now(), "Long Date")
CBC.Tag = Format(Now(), "Long Date")
CBC.OnAction = ""
Exit_CreateToolbar:
Exit Function
Err_CreateToolbar:
MsgBox Err.Description
Resume Exit_CreateToolbar
End Function
Below is the code I use and just trying to get:
"Monday, February 16, 2009" to show on the toolbar.
I added this code and got text but it is also a menu (I just want the text).
Set CBC = CB.Controls.Add(Type:=msoControlPopup)
CBC.Caption = Format(Now(), "Long Date")
CBC.Tag = Format(Now(), "Long Date")
CBC.OnAction = ""
Thanks in advance,
Mark
Public Function CreateToolbar()
On Error GoTo Err_CreateToolbar
'Creates the toolbar "RPTToolbar"
Dim MenuName As String
Dim CBS As Office.CommandBars
Dim CB As CommandBar
Dim CBC As CommandBarControl
Dim CBB As CommandBarButton
Dim CBP As CommandBarPopup
MenuName = "RPTToolbar"
'delete menu if it already exists
If fIsCreated(MenuName) Then
Application.CommandBars(MenuName).Delete
End If
'create menu and appropriate commandbuttons
Set CB = Application.CommandBars.Add(MenuName, msoBarTop, False, False)
CB.Visible = True
CB.Protection = msoBarNoMove
'*** Items off File Menu
Set CBB = CB.Controls.Add(msoControlButton, , , , True)
CBB.Caption = "Customers..."
CBB.Tag = "Customers..."
CBB.FaceId = 1099
CBB.OnAction = "=OpenForm(""frmCustomerList"")"
Set CBB = CB.Controls.Add(msoControlButton, , , , True)
CBB.Caption = "Resources..."
CBB.Tag = "Resourcess..."
CBB.FaceId = 607
CBB.OnAction = "=OpenForm(""frmResourceList"")"
'*** Items off View Menu
Set CBB = CB.Controls.Add(msoControlButton, , , , True)
CBB.Caption = "Find Avalable Time..."
CBB.Tag = "Find Avalable Time..."
CBB.FaceId = 183
CBB.OnAction = ""
CBB.BeginGroup = True
Set CBB = CB.Controls.Add(msoControlButton, , , , True)
CBB.Caption = "Search for Appointment..."
CBB.Tag = "Search for Appointment..."
CBB.FaceId = 46
CBB.OnAction = ""
'*** Items off Tools Menu
Set CBB = CB.Controls.Add(msoControlButton, , , , True)
CBB.Caption = "Email..."
CBB.Tag = "Email..."
CBB.FaceId = 24
CBB.OnAction = ""
CBB.BeginGroup = True
Set CBB = CB.Controls.Add(msoControlButton, , , , True)
CBB.Caption = "Letters..."
CBB.Tag = "Letters..."
CBB.FaceId = 42
CBB.OnAction = ""
'*** Misc Items
Set CBC = CB.Controls.Add(Type:=msoControlDropdown)
CBC.Caption = "Timescale"
CBC.Style = msoButtonAutomatic
CBC.AddItem "10 Minutes"
CBC.AddItem "15 Minutes"
CBC.AddItem "30 Minutes"
CBC.AddItem "60 Minutes"
CBC.ListIndex = 1
Set CBC = CB.Controls.Add(Type:=msoControlPopup)
CBC.Caption = Format(Now(), "Long Date")
CBC.Tag = Format(Now(), "Long Date")
CBC.OnAction = ""
Exit_CreateToolbar:
Exit Function
Err_CreateToolbar:
MsgBox Err.Description
Resume Exit_CreateToolbar
End Function