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
-
Neowin – 20 times computers embarrassed themselves with public BSODs and goofups
by
EP
1 hour, 9 minutes ago -
Slow Down in Windows 10 performance after March 2025 updates ??
by
arbrich
7 hours, 32 minutes ago -
Mail from certain domains not delivered to my outlook.com address
by
pumphouse
9 hours, 58 minutes ago -
Is data that is in OneDrive also taking up space on my computer?
by
WShollis1818
17 hours, 39 minutes ago -
Nvidia just fixed an AMD Linux bug
by
Alex5723
1 day, 11 hours ago -
50 years and counting
by
Susan Bradley
9 hours, 17 minutes ago -
Fix Bluetooth Device Failed to Delete in Windows Settings
by
Drcard:))
18 hours, 37 minutes ago -
Licensing and pricing updates for on-premises server products coming July 2025
by
Alex5723
1 day, 22 hours ago -
Edge : Deprecating window.external.getHostEnvironmentValue()
by
Alex5723
1 day, 23 hours ago -
Rethinking Extension Data Consent: Clarity, Consistency, and Control
by
Alex5723
1 day, 23 hours ago -
OneNote and MS Word 365
by
CWBillow
2 days ago -
Ultimate Mac Buyers Guide 2025: Which Mac is Right For You?
by
Alex5723
2 days, 1 hour ago -
Intel Unison support ends on Windows 11 in June
by
Alex5723
2 days, 1 hour ago -
April 2025 — still issues with AMD + 24H2
by
Kevin Jones
2 days, 1 hour ago -
Windows 11 Insider Preview build 26200.5518 released to DEV
by
joep517
2 days, 12 hours ago -
Windows 11 Insider Preview build 26120.3671 (24H2) released to BETA
by
joep517
2 days, 13 hours ago -
Forcing(or trying to) save Local Documents to OneDrive
by
PateWilliam
2 days, 21 hours ago -
Hotpatch for Windows client now available (Enterprise)
by
Alex5723
2 days, 9 hours ago -
MS-DEFCON 2: Seven months and counting
by
Susan Bradley
1 day, 10 hours ago -
My 3 monitors go black & then the Taskbar is moved to center monitor
by
saturn2233
3 days, 6 hours ago -
Apple backports fixes
by
Susan Bradley
2 days, 13 hours ago -
Win 11 24H2 will not install
by
Michael1950
1 day, 11 hours ago -
Advice to convert MBR to GPT and install Windows 11 Pro on unsupported PC
by
Andy M
4 hours, 46 minutes ago -
Photos from iPhone to Win 10 duplicating/reformatting to .mov
by
J9438
1 day, 19 hours ago -
Thunderbird in trouble. Here comes Thundermail
by
Alex5723
7 hours, 15 minutes ago -
Get back ” Open With” in context menus
by
CWBillow
3 days, 21 hours ago -
Many AMD Ryzen 9800X3D on ASRock have died
by
Alex5723
2 days, 13 hours ago -
simple general stupid question
by
WSaltamirano
3 days, 19 hours ago -
April 2025 Office non-Security updates
by
PKCano
4 days, 12 hours ago -
Microsoft wants to hear from you
by
Will Fastie
2 days, 3 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.