Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
How do I find out whether a specific button exists on the visible Standard
toolbar ? I want to add a specific extra button, but need to determine whether it already exists on the toolbar. -- |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You can use code similar to the following.
If you used the Tag property when you created the control, you can find it with FindControl searching for the Tag. Dim C As Office.CommandBarControl On Error Resume Next Err.Clear Set C = Application.CommandBars.FindControl(Tag:="your tag") If Not C Is Nothing Then Debug.Print "control exists" Else Debug.Print "control does not exist" End If If you didn't use the Tag property, you can look at the Caption that was assigned to the button. Dim C As Office.CommandBarControl On Error Resume Next Err.Clear Set C = Application.CommandBars("Standard").Controls("Capt ion") If Not C Is Nothing Then Debug.Print "control exists" Else Debug.Print "control does not exist" End If Cordially, Chip Pearson Microsoft MVP 1998 - 2010 Pearson Software Consulting, LLC www.cpearson.com [email on web site] On Mon, 18 Jan 2010 08:43:01 -0800, Paul wrote: How do I find out whether a specific button exists on the visible Standard toolbar ? I want to add a specific extra button, but need to determine whether it already exists on the toolbar. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Perfect as always.
Thankfully, I did remember to use tags -- If the post is helpful, please consider donating something to an animal charity on my behalf. "Chip Pearson" wrote: You can use code similar to the following. If you used the Tag property when you created the control, you can find it with FindControl searching for the Tag. Dim C As Office.CommandBarControl On Error Resume Next Err.Clear Set C = Application.CommandBars.FindControl(Tag:="your tag") If Not C Is Nothing Then Debug.Print "control exists" Else Debug.Print "control does not exist" End If If you didn't use the Tag property, you can look at the Caption that was assigned to the button. Dim C As Office.CommandBarControl On Error Resume Next Err.Clear Set C = Application.CommandBars("Standard").Controls("Capt ion") If Not C Is Nothing Then Debug.Print "control exists" Else Debug.Print "control does not exist" End If Cordially, Chip Pearson Microsoft MVP 1998 - 2010 Pearson Software Consulting, LLC www.cpearson.com [email on web site] On Mon, 18 Jan 2010 08:43:01 -0800, Paul wrote: How do I find out whether a specific button exists on the visible Standard toolbar ? I want to add a specific extra button, but need to determine whether it already exists on the toolbar. . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
button on toolbar | Excel Programming | |||
Identifying Button Clicked | Excel Programming | |||
Identifying Button Clicked | Excel Programming | |||
Delete a custom button by holding down the ALT key and dragging the button off the toolbar | Excel Programming | |||
Toolbar Button | Excel Programming |