Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Check to see icon exist in command bar

Sub test2()
Dim cb As CommandBarButton
On Error Resume Next
Set cb = Application.CommandBars.FindControl(Id:=2950)
On Error GoTo 0

If cb Is Nothing Then
MsgBox "no smily", , "sad"
Else
MsgBox cb.OnAction, , "smile"
End If
End Sub



Regards,
Peter T

"Richard" wrote in message
...
Hello,

The code below is to add the Smiley Icon in command bar and assign

"myMacro"
while excel file is openning so that whenever user click on the Smiley

Icon,
program process the "myMacro" coding.

The issue is that I don't want to add another Smiley Icon, if the Smile

icon
already has been added and assigned with "myMacro" while excel opened in
prior use.

How can I check to see whether it is already exist or not. If it is

already
existed on command bar, then I just want to assign a macro on the Smiley
icon; otherwise, I want to add the smiley icon and assign a macro.

Please help.

Sub AddMenuIcon()

With Application.CommandBars("Standard").Controls.Add( _
Type:=msoControlButton, _
ID:=2950, Befo=9)
.OnAction = "myMacro"
End With
End Sub



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
Check for a tab if it is exist Farhad Excel Discussion (Misc queries) 2 December 21st 08 07:31 PM
How to check worksheets exist or not ? moonhk Excel Programming 0 November 16th 06 01:47 AM
Command Line. How to tell to XL : If the xls file exist : Open it, if it does not exist : Create it. Tintin92 Excel Programming 3 March 11th 06 06:45 PM
Check if pivot already exist Tom Ogilvy Excel Programming 0 September 11th 03 05:43 AM
check if a worksheet exist - VBA Warren Excel Programming 1 September 10th 03 05:02 AM


All times are GMT +1. The time now is 10:02 AM.

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

About Us

"It's about Microsoft Excel"