Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Check for a tab if it is exist | Excel Discussion (Misc queries) | |||
How to check worksheets exist or not ? | Excel Programming | |||
Command Line. How to tell to XL : If the xls file exist : Open it, if it does not exist : Create it. | Excel Programming | |||
Check if pivot already exist | Excel Programming | |||
check if a worksheet exist - VBA | Excel Programming |