Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reporting userform Names in Excel

Status
Not open for further replies.

peterpcu

MIS
Sep 15, 2005
31
0
0
GB
Hi There,

How do you write the names of all userforms to a range of cells in a work sheet?

Or alternatively, in Excel how can you check that a particular userform exists?

Thanks

Pete

 
Hi Pete,

Easiest way is probably to try to reference it and catch the error, perhaps ..
Code:
Function UserFormExists(UserFormName As String) As Boolean
    On Error Resume Next
    temp = ActiveWorkbook.VBProject.VBComponents(UserFormName).Type
    UserFormExists = temp = vbext_ct_MSForm
End Function

You will need a reference to Microsoft VBA Extensibility for the constant (or use its value (3)).

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at VBAExpress[
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top