Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Toolbar Control Id's

Status
Not open for further replies.

slcjr777

IS-IT--Management
Feb 1, 2002
11
US
Hello all,

Can anyone tell me how to get the control id for an entire toolbar. I can get the id's for individual toolbar buttons but am having a problem enumerating the id for the entire bar.

Word and Excel 2000.

Any help would be greatly appreciated.

slcjr777
 
I use this to create text files for the ID's
Code:
Sub OutputIDs()
Dim cbr As CommandBar
Dim btn As CommandBarControl
Dim i As Integer
    Const maxid = 4000
    Open "c:\ToolbarIDs.txt" For Output As #1
    Open "c:\CommandIDs.txt" For Output As #2
    Open "c:\MenuIDs.txt" For Output As #3
    For Each cbr In Application.CommandBars
        Write #1, cbr.Index, cbr.Name
    Next cbr
    'create a temporary command bar with every available item
    Set cbr = CommandBars.Add("temporary", msoBarTop, False, True)
    For i = 1 To maxid
        On Error Resume Next
        cbr.Controls.Add ID:=i
    Next
    On Error GoTo 0
    'Write the ID and caption of each control to the output file
    For Each btn In cbr.Controls
        Write #2, btn.ID, btn.Caption
    Next
    'Delete the command Bar and close the output file
    cbr.Delete
    For Each btn In CommandBars(1).Controls
        Write #3, btn.Index, btn.Caption
    Next btn
    Close #1
    Close #2
    Close #3
End Sub

I hope this helps!



Peace! [peace]

Mike

Never say Never!!!
Nothing is impossible!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top