Excel

List All UserForm Names in Your Project

Ease of Use

Intermediate

Version tested with

2000/XP 

Submitted by:

Zack Barresse

Description:

This will display in a message box all Userforms names currently in a project. 

Discussion:

You might use this as a reference utility while you code a project. It instantly displays in a message box list all the names you have assigned to the userforms in your project. 

Code:

instructions for use

			

Option Explicit Sub ListForms() Dim x As String Dim vbc As VBIDE.VBComponent For Each vbc In ThisWorkbook.VBProject.VBComponents If vbc.Type = vbext_ct_MSForm Then Debug.Print vbc.Name x = x & vbCr & vbc.Name End If Next vbc If x = "" Then MsgBox "No UserForms created." Exit Sub End If MsgBox x End Sub

How to use:

  1. Copy the above code.
  2. Open any workbook.
  3. Press Alt + F11 to open the Visual Basic Editor (VBE).
  4. From the Menu, choose Insert-Module.
  5. Paste the code into the right-hand code window.
  6. Click Tools - References: In xl2000 and up enable "Microsoft Visual Basic For Applications Extensibility 5.3" (w/ version number); in xl97, enable "Microsoft Visual Basic For Applications Extensibility"
  7. Close the VBE, save the file if desired.
 

Test the code:

  1. Tools-Macro-Macros, and double-click ListForms.
 

Sample File:

ListForms.zip 9.61KB 

Approved by mdmackillop


This entry has been viewed 166 times.

Please read our Legal Information and Privacy Policy
Copyright @2004 - 2014 VBA Express