View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
Kevin B Kevin B is offline
external usenet poster
 
Posts: 1,316
Default List of CommandBars & Control IDs

Open a blank workbook and place the cell pointer at cell A1 of Sheet1.

Press Alt+F11 to open the VBE and then click on INSERT in the menu and
select MODULE.

Type or copy/paste the following code in the module

Sub ControlID()

Dim cb As CommandBar
Dim ctl As CommandBarControl
Dim lngRO As Long

For Each cb In Application.CommandBars
For Each ctl In cb.Controls
With Application.ActiveCell
.Offset(lngRO).Value = cb.Name
.Offset(lngRO, 1).Value = ctl.ID
.Offset(lngRO, 2).Value = ctl.Caption
End With
lngRO = lngRO + 1
Next ctl
Next cb

Set cb = Nothing
Set ctl = Nothing

End Sub

Starting in cell A1 in will list Command Bar name in column A, the button's
control ID on the command bar in column B and place the command button
caption in column C.

With the cursor somewhere in the code press F5 while in the VBE to execute,
or return to the workbook and Click TOOLS in the menu, select MACRO, MACROS.
Select the macro ControlID and click the RUN command button

Hope this helps

--
Kevin Backmann


"Silena K-K" wrote:

Hi

Does any one have a list or know how I might access one for the EXCEL 2000
and 2003 commandbars and control IDs.

In particular, I need the ID for the Format Painter button and Copy button
in both 2003 and 2000.

Thank you, Silena