Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2008

Tip: Looking for answers? Try searching our database.

How can I get list of commands and relevant the commands ID     (identification numbers)?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
avkokin - 05 Mar 2008 13:23 GMT
Hello. There is some code:
Set oBtn = oPopUp.Controls.Add(msoControlButton, 1589)
Question: how can I get list of commands and relevant the commands ID
(identification numbers)?
Thank you.
Jean-Guy Marcil - 05 Mar 2008 15:10 GMT
> Hello. There is some code:
> Set oBtn = oPopUp.Controls.Add(msoControlButton, 1589)
> Question: how can I get list of commands and relevant the commands ID
> (identification numbers)?
> Thank you.

Run this code (Depending on your system it can take a few seconds or a few
minutes...). Make sure you have nothing but a blank document active.

Option Explicit

Sub GetAllControlID()

Dim toolbarAll As CommandBar
Dim ctrAll As CommandBarControl
Dim colID As Collection
Dim colCap As Collection
Dim i As Long
Dim rgeDoc As Range

Const strLabel As String = "Toolbar Name:"
Set rgeDoc = ActiveDocument.Range
rgeDoc.Collapse wdCollapseStart

Set colID = New Collection
Set colCap = New Collection

For Each toolbarAll In Application.CommandBars
   colID.Add strLabel
   colCap.Add toolbarAll.Name
   For Each ctrAll In toolbarAll.Controls
       colID.Add ctrAll.ID
       colCap.Add ctrAll.Caption
   Next
Next

For i = 1 To colID.Count
   With rgeDoc
       .InsertAfter colID(i) & vbTab
       .InsertAfter colCap(i) & vbCrLf
       If colID(i) = strLabel Then
           With .Paragraphs(.Paragraphs.Count).Range
               With .Font
                   .Bold = True
                   .Size = 14
               End With
               With .ParagraphFormat
                   .SpaceBefore = 12
                   .SpaceAfter = 3
                   .KeepWithNext = True
               End With
           End With
       End If
   End With
Next

rgeDoc.ConvertToTable vbTab

End Sub
avkokin - 05 Mar 2008 17:01 GMT
On 5 мар, 18:10, Jean-Guy Marcil
<JeanGuyMar...@discussions.microsoft.com> wrote:
> > Hello. There is some code:
> > Set oBtn = oPopUp.Controls.Add(msoControlButton, 1589)
[quoted text clipped - 55 lines]
>
> End Sub

Thanks, Jean-Guy Marcil!
avkokin - 06 Mar 2008 08:05 GMT
> On 5 ÍÁÒ, 18:10, Jean-Guy Marcil
>
[quoted text clipped - 60 lines]
>
> Thanks, Jean-Guy Marcil!

Hello again.
How can I get list of commands (and ID) from the ribbon and commands
from groups (Word 2007)? These commands miss into the list of commands
for Toolbars, e.g. Special Paste (or PasteSpecialDialog). Thank you
very much!
Jean-Guy Marcil - 06 Mar 2008 14:19 GMT
> Hello again.
> How can I get list of commands (and ID) from the ribbon and commands
> from groups (Word 2007)? These commands miss into the list of commands
> for Toolbars, e.g. Special Paste (or PasteSpecialDialog). Thank you
> very much!

I do not have 2007 installed on my machine so I cannot test any code for that.

You should start a new thread with a specific question about 2007 so that
the 2007 experts will see it, in case they miss this thread...
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.