ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Tag in CommandBar (https://www.excelbanter.com/excel-programming/369805-tag-commandbar.html)

Desert Piranha[_99_]

Tag in CommandBar
 

Hi all,

I have read help etc. but i'm still in the dark. Could someone explai
to me the
uses for "Tag" when dealing with Command Bars?
IE:
'.Tag =
'.Caption =
'.OnAction =
'.Parameter =
'.FaceId =
'.Style =
'.BeginGroup =
'.TooltipText

--
Desert Piranh

-----------------------------------------------------------------------
Desert Piranha's Profile: http://www.excelforum.com/member.php...fo&userid=2893
View this thread: http://www.excelforum.com/showthread.php?threadid=56972


Ron de Bruin

Tag in CommandBar
 
Hi Desert

Here is a example that add a control to the Cell menu
(When you right click on a cell)

Sub AddToCellDropDown()
Dim CellDropDown As CommandBar
Dim MyDropDownItem As CommandBarControl

RemoveFromCellDropDown

Set CellDropDown = Application.CommandBars("Cell")
With CellDropDown.Controls.Add(Type:=msoControlButton, befo=1)
.Caption = "Try me"
.Style = msoButtonIconAndCaption
.FaceId = 59
.OnAction = ThisWorkbook.Name & "!Your_macro"
.Tag = "MyDropDownItem"
End With
End Sub

Sub RemoveFromCellDropDown()
Dim MyDropDownItem As CommandBarControl
Set MyDropDownItem = Application.CommandBars.FindControl(Tag:="MyDropDo wnItem")
If Not MyDropDownItem Is Nothing Then
MyDropDownItem.Delete
End If
Set MyDropDownItem = Nothing
End Sub

Sub Your_macro()
MsgBox "Hi there."
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Desert Piranha" <Desert.Piranha.2c92dv_1155088510.2116@excelforu m-nospam.com wrote in message
news:Desert.Piranha.2c92dv_1155088510.2116@excelfo rum-nospam.com...

Hi all,

I have read help etc. but i'm still in the dark. Could someone explain
to me the
uses for "Tag" when dealing with Command Bars?
IE:
'.Tag =
'.Caption =
'.OnAction =
'.Parameter =
'.FaceId =
'.Style =
'.BeginGroup =
'.TooltipText =


--
Desert Piranha


------------------------------------------------------------------------
Desert Piranha's Profile: http://www.excelforum.com/member.php...o&userid=28934
View this thread: http://www.excelforum.com/showthread...hreadid=569722




Desert Piranha[_100_]

Tag in CommandBar
 

Hi Ron,

Thanks for your input here,

So as i can see the "Tag" is just kinda like a Name for the command
Bar. Right?

So it is another way of doing this:

'Delete Command Bar
Application.CommandBars("cell").Controls("Try me").Delete
or
'Makes Command Bar temporary
With .Controls.Add(Type:=msoControlButton, temporary:=True)

And "Tag" will work with any kind of Command Bars?

And would there be any other uses for "Tag" other than deleting the
Command Bar?

Thx
Dave
Ron de Bruin Wrote:
Hi Desert

Here is a example that add a control to the Cell menu
(When you right click on a cell)

Sub AddToCellDropDown()
Dim CellDropDown As CommandBar
Dim MyDropDownItem As CommandBarControl

RemoveFromCellDropDown

Set CellDropDown = Application.CommandBars("Cell")
With CellDropDown.Controls.Add(Type:=msoControlButton, befo=1)
.Caption = "Try me"
.Style = msoButtonIconAndCaption
.FaceId = 59
.OnAction = ThisWorkbook.Name & "!Your_macro"
.Tag = "MyDropDownItem"
End With
End Sub

Sub RemoveFromCellDropDown()
Dim MyDropDownItem As CommandBarControl
Set MyDropDownItem =
Application.CommandBars.FindControl(Tag:="MyDropDo wnItem")
If Not MyDropDownItem Is Nothing Then
MyDropDownItem.Delete
End If
Set MyDropDownItem = Nothing
End Sub

Sub Your_macro()
MsgBox "Hi there."
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Desert Piranha"
<Desert.Piranha.2c92dv_1155088510.2116@excelforu m-nospam.com wrote in
message
news:Desert.Piranha.2c92dv_1155088510.2116@excelfo rum-nospam.com...

Hi all,

I have read help etc. but i'm still in the dark. Could someone

explain
to me the
uses for "Tag" when dealing with Command Bars?
IE:
'.Tag =
'.Caption =
'.OnAction =
'.Parameter =
'.FaceId =
'.Style =
'.BeginGroup =
'.TooltipText =


--
Desert Piranha



------------------------------------------------------------------------
Desert Piranha's Profile:

http://www.excelforum.com/member.php...o&userid=28934
View this thread:

http://www.excelforum.com/showthread...hreadid=569722



--
Desert Piranha


------------------------------------------------------------------------
Desert Piranha's Profile: http://www.excelforum.com/member.php...o&userid=28934
View this thread: http://www.excelforum.com/showthread...hreadid=569722


Ron de Bruin

Tag in CommandBar
 
Hi

I use it only for this but you can als use Enabled = False for example
Look on the MSDN site for more info

--
Regards Ron de Bruin
http://www.rondebruin.nl



"Desert Piranha" <Desert.Piranha.2c9zpi_1155131762.0566@excelforu m-nospam.com wrote in message
news:Desert.Piranha.2c9zpi_1155131762.0566@excelfo rum-nospam.com...

Hi Ron,

Thanks for your input here,

So as i can see the "Tag" is just kinda like a Name for the command
Bar. Right?

So it is another way of doing this:

'Delete Command Bar
Application.CommandBars("cell").Controls("Try me").Delete
or
'Makes Command Bar temporary
With .Controls.Add(Type:=msoControlButton, temporary:=True)

And "Tag" will work with any kind of Command Bars?

And would there be any other uses for "Tag" other than deleting the
Command Bar?

Thx
Dave
Ron de Bruin Wrote:
Hi Desert

Here is a example that add a control to the Cell menu
(When you right click on a cell)

Sub AddToCellDropDown()
Dim CellDropDown As CommandBar
Dim MyDropDownItem As CommandBarControl

RemoveFromCellDropDown

Set CellDropDown = Application.CommandBars("Cell")
With CellDropDown.Controls.Add(Type:=msoControlButton, befo=1)
.Caption = "Try me"
.Style = msoButtonIconAndCaption
.FaceId = 59
.OnAction = ThisWorkbook.Name & "!Your_macro"
.Tag = "MyDropDownItem"
End With
End Sub

Sub RemoveFromCellDropDown()
Dim MyDropDownItem As CommandBarControl
Set MyDropDownItem =
Application.CommandBars.FindControl(Tag:="MyDropDo wnItem")
If Not MyDropDownItem Is Nothing Then
MyDropDownItem.Delete
End If
Set MyDropDownItem = Nothing
End Sub

Sub Your_macro()
MsgBox "Hi there."
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Desert Piranha"
<Desert.Piranha.2c92dv_1155088510.2116@excelforu m-nospam.com wrote in
message
news:Desert.Piranha.2c92dv_1155088510.2116@excelfo rum-nospam.com...

Hi all,

I have read help etc. but i'm still in the dark. Could someone

explain
to me the
uses for "Tag" when dealing with Command Bars?
IE:
'.Tag =
'.Caption =
'.OnAction =
'.Parameter =
'.FaceId =
'.Style =
'.BeginGroup =
'.TooltipText =


--
Desert Piranha



------------------------------------------------------------------------
Desert Piranha's Profile:

http://www.excelforum.com/member.php...o&userid=28934
View this thread:

http://www.excelforum.com/showthread...hreadid=569722



--
Desert Piranha


------------------------------------------------------------------------
Desert Piranha's Profile: http://www.excelforum.com/member.php...o&userid=28934
View this thread: http://www.excelforum.com/showthread...hreadid=569722




Desert Piranha[_101_]

Tag in CommandBar
 

Hi Ron,

Thanks much, for the input. I think i got it figured out.

Thx again
Dave

[Ron de Bruin]Hi

I use it only for this but you can als use Enabled = False for example
Look on the MSDN site for more info

--
Regards Ron de Bruin
http://www.rondebruin.nl



"Desert Piranha"
<Desert.Piranha.2c9zpi_1155131762.0566@excelforu m-nospam.com wrote in
message
news:Desert.Piranha.2c9zpi_1155131762.0566@excelfo rum-nospam.com...

Hi Ron,

Thanks for your input here,

So as i can see the "Tag" is just kinda like a Name for the command
Bar. Right?

So it is another way of doing this:

'Delete Command Bar
Application.CommandBars("cell").Controls("Try me").Delete
or
'Makes Command Bar temporary
With .Controls.Add(Type:=msoControlButton, temporary:=True)

And "Tag" will work with any kind of Command Bars?

And would there be any other uses for "Tag" other than deleting the
Command Bar?

Thx
Dave
Ron de Bruin Wrote:
Hi Desert

Here is a example that add a control to the Cell menu
(When you right click on a cell)

Sub AddToCellDropDown()
Dim CellDropDown As CommandBar
Dim MyDropDownItem As CommandBarControl

RemoveFromCellDropDown

Set CellDropDown = Application.CommandBars("Cell")
With CellDropDown.Controls.Add(Type:=msoControlButton, befo=1)
.Caption = "Try me"
.Style = msoButtonIconAndCaption
.FaceId = 59
.OnAction = ThisWorkbook.Name & "!Your_macro"
.Tag = "MyDropDownItem"
End With
End Sub

Sub RemoveFromCellDropDown()
Dim MyDropDownItem As CommandBarControl
Set MyDropDownItem =
Application.CommandBars.FindControl(Tag:="MyDropDo wnItem")
If Not MyDropDownItem Is Nothing Then
MyDropDownItem.Delete
End If
Set MyDropDownItem = Nothing
End Sub

Sub Your_macro()
MsgBox "Hi there."
End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl



"Desert Piranha"
<Desert.Piranha.2c92dv_1155088510.2116@excelforu m-nospam.com wrote

in
message
news:Desert.Piranha.2c92dv_1155088510.2116@excelfo rum-nospam.com...

Hi all,

I have read help etc. but i'm still in the dark. Could someone

explain
to me the
uses for "Tag" when dealing with Command Bars?
IE:
'.Tag =
'.Caption =
'.OnAction =
'.Parameter =
'.FaceId =
'.Style =
'.BeginGroup =
'.TooltipText =


--
Desert Piranha




------------------------------------------------------------------------
Desert Piranha's Profile:

http://www.excelforum.com/member.php...o&userid=28934
View this thread:

http://www.excelforum.com/showthread...hreadid=569722



--
Desert Piranha



------------------------------------------------------------------------
Desert Piranha's Profile:

http://www.excelforum.com/member.php...o&userid=28934
View this thread:

http://www.excelforum.com/showthread...hreadid=569722



--
Desert Piranha


------------------------------------------------------------------------
Desert Piranha's Profile: http://www.excelforum.com/member.php...o&userid=28934
View this thread: http://www.excelforum.com/showthread...hreadid=569722



All times are GMT +1. The time now is 07:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com