Please Note: This article is written for users of the following Microsoft Word versions: 2007, 2010, 2013, 2016, 2019, and Word in Microsoft 365. If you are using an earlier version (Word 2003 or earlier), this tip may not work for you. For a version of this tip written specifically for earlier versions of Word, click here: Printing a Macro List.
Written by Allen Wyatt (last updated October 23, 2021)
This tip applies to Word 2007, 2010, 2013, 2016, 2019, and Word in Microsoft 365
Many Word users rely upon macros to perform all sorts of tasks in the program. Over the years it is possible to accumulate quite a few different macros. At some point you may want a way to print out a list of your macros for reference purposes. Unfortunately, Word doesn't provide a way you easily print out such a macro list.
If you just need a quick list, one way to do it is to use Word's built-in tools to list all the commands available to Word. Since Word considers macros to be "commands," the command list will also include your macros. But since you don't want all the other commands in Word (besides your macros), you will need to do a little editing. Follow these steps:
Figure 1. The Macros dialog box.
Word then creates a new document that contains a table with all Word commands. Remember that your macros are buried within the table. To find them, search for "normal." (make sure you include the period, but not the quote marks). This finds any "commands" contained in the Normal document template. You can copy the names of these commands—they are your macros—to a different document. If you have macros in any other templates, search for those template names, as well.
Another approach is to follow these general steps:
Figure 2. The Replace tab of the Find and Replace dialog box.
What you instructed Word to do was to delete everything except the subroutine names (these are your macro names). What is not included in this process are any functions you may have created in your macros. Those functions are not publicly available macros, so for most people this isn't a big issue.
Note:
WordTips is your source for cost-effective Microsoft Word training. (Microsoft Word is the most popular word processing software in the world.) This tip (13041) applies to Microsoft Word 2007, 2010, 2013, 2016, 2019, and Word in Microsoft 365. You can find a version of this tip for the older menu interface of Word here: Printing a Macro List.
Create Custom Apps with VBA! Discover how to extend the capabilities of Office 2013 (Word, Excel, PowerPoint, Outlook, and Access) with VBA programming, using it for writing macros, automating Office applications, and creating custom applications. Check out Mastering VBA for Office 2013 today!
Inserting a break in your document is easy. You may think that inserting one using a macro is more complex, but it isn't. ...
Discover MoreThe Open dialog box is one that few of us think about, but you can control how it behaves with a little bit of macro ...
Discover MoreMacros are very good at completing mundane, repetitive tasks. For instance, you could use the macro presented in this tip ...
Discover MoreFREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
2021-11-12 22:25:47
Tomek
The document created as described in the first part of the tip is very useful. Beware however, that for user macros the two other columns: Modifier and Key, are not showing the shortcut keys even if they are assigned to the macro. At least this is the result I got in my limited testing.
There was another tip that showed how to print key assignment list, which includes only user-assigned keys.
https://wordribbon.tips.net/T009256_Printing_a_Key_Assignment_List
Unluckily, I was not able to find something similar for Excel :-( On the other hand, an approach proposed by Ken Endacott should work. I think I saw an Excel tip recently with a similar macro.
@Kiwerry: this may be relevant to our recent discussion.
2021-11-08 04:48:32
Ken Endacott
Kiwerry,
If the macro is your document for example MyMacros.docm, open MyMacros.docm then open Normal.dotm. Minimise MyMacros.docm leaving Normal.dotm visible and run the macro.
Regarding Public and Private it is just a matter of adding
Or Left(s,6) = “Public” Or Left(s,7) = “Private”
There is a shortcoming to the macro as it stands. It only finds macros in modules, it doesn’t find macros in other parts of the project such as controls.
2021-11-07 13:43:35
Kiwerry
Thanks for a useful tool, Ken. I have a question and a comment:
How can I get a list of the procedures in my Normal template? I tried replacing fname with the full path of Normal.dotm ("c:\Users\[anon]\AppData\Roaming\Microsoft\Templates\Normal.dotm") but that generated a "Bad File Name" error. The name was correct: I navigated to the file and transferred the full path to the code using the clipboard.
If one has used the Public or Private qualifiers then the check for a sub or function will have to be more than just looking at the first three characters in a line (If Left(s, 3) = "Sub" ...)
2021-10-23 18:52:38
Ken Endacott
Here is a macro that will create a list of macros in the currently open document or template. For example if you want a list of macros in the Normal template then open the template and run the macro.
The list is copied into a new document.
Before running the macro make sure that "Microsoft Visual Basic for Applications Extensibility 5.3" is checked in Tools > References.
Sub CreateMacroList()
' Microsoft Visual Basic for Applications Extensibility 5.3
' must be set in Tools > References
Dim vbComp As VBIDE.VBComponent
Dim fName As String
Dim s As String
Dim j As Long
Dim k As Long
fName = ActiveDocument.Name
Documents.Add
For Each vbComp In Documents(fName).VBProject.VBComponents
If vbComp.Type = vbext_ct_StdModule Then
Selection.TypeText vbCrLf & vbComp.Name & vbCrLf
j = vbComp.CodeModule.CountOfLines
If j > 0 Then
For k = 1 To j
s = Trim(vbComp.CodeModule.Lines(k, 1))
If Left(s, 3) = "Sub" Or Left(s, 6) = "Function" Then _
Selection.TypeText s & vbCrLf
Next k
End If
End If
Next vbComp
ActiveDocument.Range.NoProofing = True
End Sub
Got a version of Word that uses the ribbon interface (Word 2007 or later)? This site is for you! If you use an earlier version of Word, visit our WordTips site focusing on the menu interface.
Visit the WordTips channel on YouTube
FREE SERVICE: Get tips like this every week in WordTips, a free productivity newsletter. Enter your address and click "Subscribe."
Copyright © 2024 Sharon Parq Associates, Inc.
Comments