Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I am trying to get tooltips on my menu that I have added to the standard Excel menu. I have created my menu with Application.CommandBars(1).Controls. _ Add(Type:=msoControlPopup, befo=10, temporary:=True) The .TooltipText="My tooltip" does not seem to work. When the menu is created with: Application.CommandBars.Add(Name:="myMenuBar", Position:=msoBarTop, _ MenuBar:=False) The .TooltipText="My tooltip" does work. Samples of two codes are below What is the difference between Application.CommandBars.Add Application.CommandBars(1).Controls.Add I have tried to read the Excel VBA help but am struggling to make sense of it. It seems that the one is adding another Command bar and the second is adding more controls to an existing command bar. Why does the .TooltipText work in the one and not the other? I cannot find .TooltipText as a member of either the CommandBars or Controls Class in the object browser. --------------------------------------------------- 'CommandBars(1).Controls. menu Sub CreateMyMenuTest() DeleteMyMenu 'Calls the Sub below Dim M1 As CommandBarPopup Set M1 = Application.CommandBars(1).Controls. _ Add(Type:=msoControlPopup, befo=10, temporary:=True) M1.Caption = "&My Tools" With M1.Controls.Add(Type:=msoControlButton) .Caption = "&Test Macro" .TooltipText = "My Test Macro tooltip" .FaceId = 123 .BeginGroup = False .OnAction = "TTest2" End With With M1.Controls.Add(Type:=msoControlButton) .Caption = "&Delete Mennu" .TooltipText = "Delete menu item" .FaceId = 123 .BeginGroup = False .OnAction = "DeleteMyMenuTest" End With End Sub Sub TTest2() 'MsgBox ("SKB Test Macro") MsgBox "Hello" & vbLf & "World" End Sub Sub DeleteMyMenuTest() Dim MU As CommandBarPopup On Error Resume Next Set MU = Application.CommandBars(1).Controls("&My Tools") MU.Delete End Sub --------------------------------------------------- 'CommandBars. menu Sub MakeMenuBar() On Error Resume Next Application.CommandBars("MyMenuBar").Delete On Error GoTo 0 With Application.CommandBars.Add(Name:="myMenuBar", Position:=msoBarTop, _ MenuBar:=False) With .Controls.Add(Type:=msoControlButton) .Style = msoButtonCaption .Caption = "Click me" .TooltipText = "your text 1" .OnAction = "MenuBarMacro" End With With .Controls.Add(Type:=msoControlButton) .Style = msoButtonCaption .BeginGroup = True .Caption = "Delete the MenuBar" .TooltipText = "your text 2" .OnAction = "DeleteMenuBar" End With .Visible = True End With End Sub Sub MenuBarMacro() MsgBox "Hi" End Sub Sub DeleteMenuBar() On Error Resume Next Application.CommandBars("MyMenuBar").Delete On Error GoTo 0 End Sub Any assistance will be appreciated. Sean |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Commandbars - again | Excel Programming | |||
Commandbars | Excel Programming | |||
CommandBars("Worksheet Menu Bar").Controls("Tools").Enabled = Fals | Excel Programming | |||
Commandbars | Excel Programming | |||
CommandBars | Excel Programming |