Commandbar question

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
 
M

Mark Andrews

I found the Style property of a command bar button which allows for text,
icon or both.

So now I have a button with text that does nothing. Close to what I want.

Anyway to make it so the button can't be clicked? disabling sets the text
to gray so that won't work.

Also anyway to get it so the user can't customize toolbars in general. The
toolbar has the "Add or Remove Buttons" menu at the end of it which allows
for the user to change things. I am setting CB.Protection which helps but
doesn't take the menu at the end off.

Planning on turning this database into an MDE.

Thanks in advance,
Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top