Copying UserForms programmatically
This program would copy Userforms in ThisWorkbook the new workbook programmatically.
Looping each VBComponent objects and if the type of the VBComponent is 3 (stands for an Userform), exports the form then import it from the new workbook. At last, This program would removes all exported files.
Please note, if you are using Excel 2002(XP) and the later, to run this program, you need to tick Trust access to Visual Basic Project
from main menu.
Place the following in the standard module.
'// UserForms of ThisWorkbook Copy to New Workbook.
Dim objVbc As Object, wbNew As Workbook
Set wbNew = Workbooks.Add
For Each objVbc In ThisWorkbook.VBProject.VBComponents
If objVbc.Type = 3 Then
'// Export Form
'// Import Form to new workbook
'// Kill Form Files
Kill objVbc.Name & ".frx"
Set wbNew = Nothing
Tips and Information about Microsoft Excel｜Masaru Kaji aka Colo