Sub GetFindControlID()
Dim a As CommandBarControls
Dim b As Object
Dim buf() As Variant
Dim i As Long
Set a = Application.CommandBars.FindControls
'loop commandbars object
For Each b In a
i = i + 1
ReDim Preserve buf(1 To 2, 1 To i)
buf(1, i) = b.Caption
buf(2, i) = b.ID
Next
'output result
Application.ScreenUpdating = False
[A1].Resize(, 2).Value = Array("Caption", "ID")
[A2].Resize(UBound(buf, 2), 2).Value = myTranspose(buf)
'format a table
[A1].AutoFormat Format:=xlRangeAutoFormatColor2, Number:=True, Font _
:=True, Alignment:=True, Border:=True, Pattern:=True, Width:=True
[A1].Resize(, 2).HorizontalAlignment = xlCenter
Application.ScreenUpdating = True
MsgBox "Done"
End Sub
Function myTranspose(buf)
Dim i As Long
Dim j As Long
Dim a() As Variant
ReDim a(1 To UBound(buf, 2), 1 To UBound(buf, 1))
For i = LBound(buf, 1) To UBound(buf, 1)
For j = LBound(buf, 2) To UBound(buf, 2)
a(j, i) = buf(i, j)
Next
Next
myTranspose = a
End Function
Sub Test1()
'this code would show the "Find and Replace" dialogue box.
Application.CommandBars.FindControl(ID:=1849).Execute
End Sub