A macro to list all word cmds and their descriptions ?

M

Mitrokhin

I would like to have a complete list with all the word commands
plus their descriptions but i can't make VBA do what i want it to :(

In wordbasic you could write something like this:

Sub MAIN
FileNewDefault
For NumTmpltMax = 1 To CountMacros(0, 1, 0)
InsertPara
Bold 1 : Insert MacroName$(NumTmpltMax, 0, 1, 0) : Bold 0 : Insert
Chr$(32)
Insert MacroDesc$(MacroName$(NumTmpltMax, 0, 1, 0))
Next NumTmpltMax
InsertPara
End Sub

and it works, but i can't for the live of me find an equivalent to
the above functions in VBA.

I'am aware that the Word MVP site carries a list like this but i want
to see precisely which commands _Word X for the Macintosh_ (VBA5)
supports.

Can anyone help ?
 
K

Klaus Linke

Hi Mitrokhin,

Your WordBasic code seems to list the modules in Word2002.
From the text, I guess you want a list of the built-in commands and their
descriptions?

You could expand a lot on the macro below (type of control? on which
toolbars/menus is it found? does it take arguments? ...), but it may get you
started.
In case the macro crashes, you may want to delete the toolbar "Test"
manually.

Regards,
Klaus


Sub ListMyCommands()
On Error Resume Next
' Better save your work before you start
Dim i
Dim myCB As CommandBar
Set myCB = CommandBars.Add("Test")
Dim myCBC As CommandBarControl
For i = 1 To &HFFFF&
Set myCBC = CommandBars("Test").Controls.Add(ID:=i)
If myCBC Is Nothing Then
Else
ActiveDocument.Content.InsertAfter i _
& ": " & myCBC.Caption _
& vbTab & myCBC.DescriptionText _
& vbCr
myCBC.Delete
End If
Next i
CommandBars("Test").Delete
End Sub
 
M

Mitrokhin

In: microsoft.public.mac.office.word
Thu, 18 Dec 2003 17:11:00 -0000
MsgID: <#[email protected]>
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Jonathan West said:
Hi Mitrokhin

Unfortunately there is no equivalent in VBA

Hi,

No I guess not but is it possible with the Word Object collection ?
(if that's the right term :).

I wonder how this list was made,
http://www.mvps.org/word/Downloads/WordCommands.zip
and I found the VBA code below somewhere (Can't remember where)
and it does try to do what i'am looking for sort of and in a roundabout
way, but the resulting list isn't in alfabetical order and it also
seems to miss out on a number of commands.

Could it be that in this particular instance VBA doesn't match
Wordbasic in functionality ?

_________

Sub outputIDs()

' Create a temporary command bar with every
' available item and control assigned to it.
Set cbr = CommandBars.Add("Temporary", msoBarTop, False, True)

For I = 0 To 4000 ' adjust to 1000 or it'll crash macword
' [Mitrokhin]
On Error Resume Next
cbr.Controls.Add ID:=I
Next

'Write the ID and caption of each control to the output file.

For Each Btn In cbr.Controls
Btn.CopyFace
Selection.InsertAfter Btn.ID
Selection.InsertAfter Chr$(9)
Selection.InsertAfter Btn.Caption
Selection.InsertAfter Chr$(9)
Selection.InsertAfter Btn.ShortcutText
Selection.InsertAfter Chr$(9)
Selection.InsertAfter Btn.TooltipText
Selection.InsertAfter Chr$(9)
Selection.InsertAfter Btn.DescriptionText
Selection.InsertAfter Chr$(9)
Selection.InsertAfter Btn.FaceId
Selection.InsertAfter Chr$(9)
Selection.Collapse Direction:=wdCollapseEnd
Selection.PasteSpecial Placement:=wdInLine
WordBasic.InsertPara
WordBasic.FileSave ' move this up bef. the For Each cmd.
' [Mitrokhin]
Next
cbr.Delete
End Sub
 
M

Mitrokhin

In: microsoft.public.mac.office.word,microsoft.public.word.vba.general
Thu, 18 Dec 2003 19:17:02 +0100
MsgID: <[email protected]>
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Hi,
Hi Mitrokhin,

Your WordBasic code seems to list the modules in Word2002.
From the text, I guess you want a list of the built-in commands and their
descriptions?

You could expand a lot on the macro below (type of control? on which
toolbars/menus is it found? does it take arguments? ...), but it may get you
started.
In case the macro crashes, you may want to delete the toolbar "Test"
manually.

Regards,
Klaus


Sub ListMyCommands()
On Error Resume Next
' Better save your work before you start
Dim i
Dim myCB As CommandBar
Set myCB = CommandBars.Add("Test")
Dim myCBC As CommandBarControl
For i = 1 To &HFFFF&
Set myCBC = CommandBars("Test").Controls.Add(ID:=i)
If myCBC Is Nothing Then
Else
ActiveDocument.Content.InsertAfter i _
& ": " & myCBC.Caption _
& vbTab & myCBC.DescriptionText _
& vbCr
myCBC.Delete
End If
Next i
CommandBars("Test").Delete
End Sub

Ok thanks Klaus, i'll give it a try and return to this thread. Your
solution certainly looks more elegant than the one i give in
<181220031939042356%[email protected]> and i wasn't
aware that there was any room for experimentation.


Regards,
 
K

Klaus Linke

Hi Mitrokhin,

I did a list about a year or two ago, and used your technique (file save
after each command) too, because Word was constantly crashing.

The macro I posted ran without a hitch in Word2002.

But if you try to get more detailed information for each command, you're
bound to have a couple of crashes.
I think even my simple version crashed for some command in Word2000.

One big problem I found is that there doesn't seem to be an easy way to
match up the Caption you get from the control with the
correspondingWordBasic command (say, the control with Id:=2 and Caption
"Spelling..." to WordBasic.ToolsSpelling).
I matched them up through the description text, which seems to be the same
if the control runs a certain built-in command.

Another problem is the fact that quite a few commands only "work" under
certain circumstances (say, if you're in a table).

IIRC, unless these circumstances are met, you often only get limited
information by querying the control you created on your toolbar.

Regards,
Klaus
 
M

Mitrokhin

In: microsoft.public.mac.office.word,microsoft.public.word.vba.general
Thu, 18 Dec 2003 20:16:58 +0100
MsgID: <[email protected]>
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

Hi Mitrokhin,

Hi again :),
I did a list about a year or two ago, and used your technique (file save
after each command) too, because Word was constantly crashing.

The macro I posted ran without a hitch in Word2002.

But if you try to get more detailed information for each command, you're
bound to have a couple of crashes.
I think even my simple version crashed for some command in Word2000.

One big problem I found is that there doesn't seem to be an easy way to
match up the Caption you get from the control with the
correspondingWordBasic command (say, the control with Id:=2 and Caption
"Spelling..." to WordBasic.ToolsSpelling).
I matched them up through the description text, which seems to be the same
if the control runs a certain built-in command.

Another problem is the fact that quite a few commands only "work" under
certain circumstances (say, if you're in a table).

IIRC, unless these circumstances are met, you often only get limited
information by querying the control you created on your toolbar.

Regards,
Klaus

Great info, i'll look into it shortly.

Btw. i found out where i got the code from i cited in that other
article: It's from a help file called VBAReference that lists alot of
Word 97 commands along with icons and descriptions. If you
want it - it's a 236kb .ZIP file - let me know.

Thanks again,


Regards,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top