Is there a way to create a list of all of my Modules and macros in those modules that are in my personal.xls file?
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
Create list of all macros in personal workbook (Excel 2000 SR1)
Home » Forums » AskWoody support » Productivity software by function » MS Excel and spreadsheet help » Create list of all macros in personal workbook (Excel 2000 SR1)
- This topic has 14 replies, 8 voices, and was last updated 18 years, 10 months ago.
AuthorTopicWSBillSutterfield
AskWoody LoungerJuly 13, 2005 at 1:41 pm #421792Viewing 1 reply threadAuthorReplies-
WSBrooke
AskWoody LoungerJuly 13, 2005 at 2:09 pm #959588Here’s some quick and dirty code I cobbled together some time ago – there are probably tidier ways of doing this. I’m not sure, but the original source would probably have been either here, j-walk or chip (but all errors are mine entirely!) This works on the active workbook only.
Sub ListFuncsAndProcs() Dim aComp Dim WkBkComps Set WkBkComps = ActiveWorkbook.VBProject.VBComponents Dim RowVal As Integer, colval As Integer Application.DisplayAlerts = False On Error Resume Next Sheets("list of funcs and procs").Delete On Error GoTo 0 Application.DisplayAlerts = True Sheets.Add.Name = "list of funcs and procs" ActiveWindow.Zoom = 50 colval = 1 Cells(1, colval).Value = ".Name" Cells(2, colval).Value = ".Type" Cells(3, colval).Value = ".codemodule" Cells(4, colval).Value = ".count of lines" ActiveSheet.UsedRange.EntireColumn.AutoFit colval = 2 Dim intCol As Integer On Error Resume Next For Each aComp In WkBkComps Cells(1, colval).Value = aComp.Name Cells(2, colval).Value = aComp.Type Cells(3, colval).Value = aComp.CodeModule intCol = aComp.CodeModule.CountOfLines Cells(4, colval).Value = intCol Dim x RowVal = 5 Dim strtemp For x = 1 To intCol strtemp = aComp.CodeModule.Lines(x, 1) If Left(strtemp, 8) = "Function" Then Cells(RowVal, colval).Value = strtemp: RowVal = RowVal + 1: End If If Left(strtemp, 16) = "Private Function" Then Cells(RowVal, colval).Value = strtemp: RowVal = RowVal + 1: End If If Left(strtemp, 15) = "Public Function" Then Cells(RowVal, colval).Value = strtemp: RowVal = RowVal + 1: End If If Left(strtemp, 3) = "Sub" Then Cells(RowVal, colval).Value = strtemp: RowVal = RowVal + 1: End If If Left(strtemp, 11) = "Private Sub" Then Cells(RowVal, colval).Value = strtemp: RowVal = RowVal + 1: End If If Left(strtemp, 10) = "Public Sub" Then Cells(RowVal, colval).Value = strtemp: RowVal = RowVal + 1: End If Next colval = colval + 1 Next End Sub
-
WSHansV
AskWoody Lounger -
WSBrooke
AskWoody Lounger -
WSBillSutterfield
AskWoody Lounger
-
-
-
H. Legare Coleman
AskWoody PlusJuly 13, 2005 at 2:54 pm #959599Attached is a workbook that can be used to get a list of the modules and code in a workbook. It also produces either a .rtf or .txt file that contains a listing of the procedures and functions. The .rtf file can be used to print a formatted listing of all of the code in the workbook. This only works for standard modules, not class modules. To use the workbook, open the workbook and click on the PrintWBCode button. Select the options you want in the dialog box and click OK. Then find the workbook you want to print the code from, select it and click on the Open button. You should get a list of the modules, the procedure/function names, along with some information about them. Select a name and location for the .rtf or .txt file and click on OK. You can then save the workbook with the module and procedure list.
-
WSclockwork
AskWoody Lounger -
WSfburg
AskWoody LoungerMay 27, 2006 at 4:45 pm #1013724Legare,
I tried your code and seems useful. But it crashed with an error saying “Programmatic access to Visual Basic Project is not trusted.”
I have a number of add-ins in my Excel environment that are password-protected. I also have an add-in that is not so protected. I created a trivial workbook with a macro built by the recorder for testing.
The crash came in your sub BuildProcList in about the first executable line (For each ocomponent …).
I wasn’t sure if the protected add-ins were the culprit but haven’t unloaded them to test.
Fred
-
H. Legare Coleman
AskWoody Plus -
WSpieterse
AskWoody LoungerMay 28, 2006 at 8:23 am #1013758 -
WSfburg
AskWoody LoungerMay 28, 2006 at 12:01 pm #1013765Jan Karel and Legare,
I understand about the protected projects. It would seem that many people might have such projects – for example, I have 2 protected projects, one of which is the analysis toolpack for VBA as an add-in (atpvbaen). I’d think the analysis toolpack is another. But I would not have the passwords.
I am more than happy to forego seeing the listing of modules and macros in such projects. However, it would seem useful to be able to see modules and macros for unprotected projects even though there are other protected projects in one’s environment. For example for things that I write. It does not seem useful to have to unload protected projects to be able to see a listing and then add them back in.
As an experiment, I have a unprotected project called Conversions for converting all kinds of units that I got off the lounge some time ago. I changed the name of it to aaConversions so it came first in the list of projects. Then I ran Legare’s macro. It stopped for the same reason. I tried to check if any info had been gathered but couldn’t find any. I also don’t know if the name change really had any effect as far as Legare’s macro goes – the crash occurs in the loop for each component of projects so it’s unclear if renaming things changed the order in which the loop checks projects.
So is there a way to find that a project is protected and bypass that one? Even if so, I would not bother to prompt for a password. Perhaps just include that project’s name in the output and indicate it’s protected?
Fred
-
WSsdckapr
AskWoody LoungerMay 28, 2006 at 1:32 pm #1013771(Edited by sdckapr on 28-May-06 10:32. Added PS)
I am confused. Legare’s code works on 1 file and its code must be unprotected or you get and error. Even if other workbooks are open with protected projects, you do not get the error. You only get the error when you try to read workbooks that are project protected.
If you are going thru a list of workbooks, you could trap the error, do something else, then resume. But how you do it depends on what your code is doing.
Steve
PS for example in Legare’s “PrintWBCode” subroutine, you could add the red lines to the existing code to indicate the problem and do something elseOn Error Resume Next
lPCount = BuildProcList(wbCode)
If Err.Number = 50289 Then
MsgBox Err.Description & vbCrLf & _
“Add your code here”
Exit Sub
End If
On Error GoTo 0
With wbMe.Worksheets(“Sheet1”) -
WSfburg
AskWoody LoungerMay 28, 2006 at 9:01 pm #1013812Steve,
You’re right about the number of files being accessed. I’ve solved the problem. Actually I had 2 issues:
– I didn’t have the box checked for allowing access to VBA projects since I thought I read somewhere that isn’t a good practice. This solved the problem I originally posted.– I had saved Legare’s original post (not the attachment) as part of my downloaded copy of his workbook. I put the text of the post in Sheet 2 and renamed it to “Lounge Post”. Then I moved this sheet to be the first sheet in the workbook. Even though there was a Sheet1 named Sheet1, it appears that the ordering of worksheets is important. I saw in the code that there was a reference to Sheet1. Even tho the VBA env shows his original Sheet1 as being in the first position regardless of the ordering of the sheets in the workbook, the ordering does seem to make a difference.
Fred
-
WSsdckapr
AskWoody LoungerMay 29, 2006 at 1:17 am #1013821When the code uses :
Worksheets("Sheet1")
It is referring to a sheet literally named “Sheet1” and is independent of the order of the sheets.
When the code uses:
Worksheets(1)
It is referring to the first worksheet in the workbook and the name is unimportant, it is solely based on the order.
Steve
-
WSfburg
AskWoody Lounger
-
-
-
Viewing 1 reply thread -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Registry Patches for Windows 10
by
Drcard:))
49 minutes ago -
Cannot get line length to NOT wrap in Outlining in Word 365
by
CWBillow
1 hour, 2 minutes ago -
DDU (Display Driver Uninstaller) updates
by
Alex5723
4 hours, 37 minutes ago -
Align objects on a OneNote page
by
CWBillow
6 hours, 17 minutes ago -
OneNote Send To button?
by
CWBillow
7 hours, 1 minute ago -
WU help needed with “Some settings are managed by your organization”
by
Peobody
15 hours, 34 minutes ago -
No Newsletters since 27 January
by
rog7
11 hours, 31 minutes ago -
Linux Mint Debian Edition 7 gets OEM support, death of Ubuntu-based Mint ?
by
Alex5723
20 hours, 4 minutes ago -
Windows Update “Areca Technology Corporation – System – 6.20.0.41”
by
Bruce
4 hours, 6 minutes ago -
Google One Storage Questions
by
LHiggins
49 minutes ago -
Button Missing for Automatic Apps Updates
by
pmcjr6142
1 hour, 53 minutes ago -
Ancient SSD thinks it’s new
by
WSila
14 hours, 39 minutes ago -
Washington State lab testing provider exposed health data of 1.6 million people
by
Nibbled To Death By Ducks
1 day, 6 hours ago -
WinRE KB5057589 fake out
by
Susan Bradley
23 hours, 42 minutes ago -
The April 2025 Windows RE update might show as unsuccessful in Windows Update
by
Susan Bradley
14 hours, 20 minutes ago -
Firefox 137
by
Charlie
10 hours, 39 minutes ago -
Whisky, a popular Wine frontend for Mac gamers, is no more
by
Alex5723
1 day, 18 hours ago -
Windows 11 Insider Preview build 26120.3863 (24H2) released to BETA
by
joep517
1 day, 18 hours ago -
Windows 11 Insider Preview build 26200.5551 released to DEV
by
joep517
1 day, 19 hours ago -
New Windows 11 PC setup — can I start over in the middle to set up a local id?
by
ctRanger
14 hours, 49 minutes ago -
Windows 11 Insider Preview Build 26100.3902 (24H2) released to Release Preview
by
joep517
1 day, 22 hours ago -
Oracle kinda-sorta tells customers it was pwned
by
Nibbled To Death By Ducks
2 days, 4 hours ago -
Global data centers (AI) are driving a big increase in electricity demand
by
Kathy Stevens
2 days, 14 hours ago -
Office apps read-only for family members
by
b
2 days, 17 hours ago -
Defunct domain for Microsoft account
by
CWBillow
2 days, 14 hours ago -
24H2??
by
CWBillow
14 hours, 43 minutes ago -
W11 23H2 April Updates threw ‘class not registered’
by
WindowsPersister
10 hours, 36 minutes ago -
Master patch listing for April 8th, 2025
by
Susan Bradley
14 hours, 33 minutes ago -
TotalAV safety warning popup
by
Theodore Nicholson
1 day, 13 hours ago -
two pages side by side land scape
by
marc
4 days, 15 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.