LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default CommandBars vs CommandBars(1).Controls

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Commandbars - again micklloyd[_5_] Excel Programming 4 January 30th 06 08:32 AM
Commandbars PosseJohn Excel Programming 1 December 16th 05 05:51 PM
CommandBars("Worksheet Menu Bar").Controls("Tools").Enabled = Fals Arturo Excel Programming 3 May 26th 05 05:44 PM
Commandbars Libby Excel Programming 1 August 8th 04 07:11 PM
CommandBars garry Excel Programming 3 June 24th 04 03:12 PM


All times are GMT +1. The time now is 08:35 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"