Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 661
Default Identifying a button on a toolbar

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Identifying a button on a toolbar

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 661
Default Identifying a button on a toolbar

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
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
button on toolbar tango Excel Programming 2 October 21st 04 08:46 AM
Identifying Button Clicked Tom Ogilvy Excel Programming 0 July 23rd 04 06:38 PM
Identifying Button Clicked Chip Pearson Excel Programming 0 July 23rd 04 06:29 PM
Delete a custom button by holding down the ALT key and dragging the button off the toolbar Stephen[_8_] Excel Programming 0 April 4th 04 02:22 PM
Toolbar Button Gary Chan Excel Programming 4 August 21st 03 09:20 PM


All times are GMT +1. The time now is 08:34 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"