List Of Userforms And Modules

Jaye7

Well-known Member
Joined
Jul 7, 2010
Messages
1,060
Can anyone please provide a script that lists all of the userforms in my file named Excel Template in Listbox1 and a script that lists all of the modules in the same workbook in listbox2.

I don't want to list the macros in the modules though, just the modules themselves.

Thanks
 

Excel Facts

Add Bullets to Range
Select range. Press Ctrl+1. On Number tab, choose Custom. Type Alt+7 then space then @ sign (using 7 on numeric keypad)
Chip's site doesn't help, I have found a procedure for listing modules, sheets and userforms, but not one for just userforms.

the code for modules is

Code:
Dim VBComp As VBIDE.VBComponent
With ListBox1
.Clear
For Each VBComp In ThisWorkbook.VBProject.VBComponents
If VBComp.Type = vbext_ct_StdModule Then
.AddItem VBComp.Name
End If
Next VBComp
.ListIndex = 0
End With

the code for modules, forms and sheets is

Code:
Dim VBComp As VBIDE.VBComponent
With Me.ListBox1
.Clear
For Each VBComp In ThisWorkbook.VBProject.VBComponents
.AddItem VBComp.Name
Next VBComp
.ListIndex = 0
End With

But I want one that just lists the userforms only.
 
Upvote 0
Chip's site doesn't help, I have found a procedure for listing modules, sheets and userforms, but not one for just userforms.

...

But I want one that just lists the userforms only.

Hi Jaye

Maybe you missed it when you studied Chip's page?

VBComponent

A VBComponent is one object within the VBProject. A VBComponent is a code module, a UserForm, a class module, one of the Sheet modules, or the ThisWorkbook module (together, the Sheet modules and the ThisWorkbook module are called Document Type modules.. A VBComponent is of one of the following types, identified by the Type property. The following constants are used to identify the Type. The numeric value of each constant is shown in parentheses.

  • vbext_ct_ClassModule (2): A class module to create your own objects. See Class Modules for details about classes and objects.
  • vbext_ct_Document (100): One of the Sheet modules or the ThisWorkbook module.
  • vbext_ct_MSForm (3): A UserForm. The visual component of a UserForm in the VBA Editor is called a designer.
  • vbext_ct_StdModule (1): A regular code module. Most of the procedures on this page will work with these types of components.
 
Upvote 0
Thanks PGC but I have very basic VBA skills so don't know how to incorporate that as a VBA script, can you please help with it, the other scripts I found on other threads.
 
Upvote 0
Thanks PGC I managed to get the code working using the script that you provided. Much appreciated.
 
Upvote 0
Hi. I was coming back to this thread but I see you already solved the problem, which is great. I'm glad it's solved.
 
Upvote 0

Forum statistics

Threads
1,215,421
Messages
6,124,806
Members
449,191
Latest member
rscraig11

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top