Go through all the userforms of a workbook

安稳与你 提交于 2020-01-13 12:34:01

问题


I would like to write a VBA program that prints the name of all the userforms in a workbook.

For instance, if a workbook has a userform called frmHello. I just want to print UserForm: frmHello

Does anyone know which collection is about userforms, and how to find the name of a userform?


回答1:


This one works for me:

Dim c As Object
For Each c In ThisWorkbook.VBProject.VBComponents
     If c.Type = 3 Then
         MsgBox c.Name
     End If
Next


来源:https://stackoverflow.com/questions/23547832/go-through-all-the-userforms-of-a-workbook

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!