Hi
I need to create a variable number of userforms at runtime to provide the user with a list of questions. These will be selected by a previous userform.
So the Level 1 form will determine which Level 2 questions are asked. The level 2 questions will be shown in blocks of 10 to the user for their answers, the answers need to be saved between opening and closing the file so I will pass the answers to a worksheet. The user needs to be able to move back and forth through the userforms in order to answer some questions at a later date.
My plan is to dynamically create the userforms based on the answers to the level 1 questions, pass the answers to a sheet and pass them back to the form the next time it is created.
So far I run the macro, create a new workbook (wbDest) and copy over the modules and references from the original workbook, then call the macro to create the userforms in the new workbook (wbDest).
The below code generates a runtime error 75 path/file not found when creating the userform, I need to solve this as I need the level 2 userforms to have different names in order to pass the answers back to the userform in the correct order, on subsequent uses. If it makes a difference in the code the object references are all Public
Dim frmQuestionsL1 As VBComponent
Dim lbLabel As MSForms.Label
Dim wbDest As Workbook
Dim r As Long
Set frmQuestionsL1 = wbDest.VBProject.VBComponents.Add(vbext_ct_MSForm)
With frmQuestionsL1
.Properties("Height") = 274
.Properties("Width") = 608.5
.Properties("Caption") = "Level 1 Questions"
.Properties("BackColor") = RGB(255, 255, 255)
.Properties("BorderStyle") = fmBorderStyleNone
.Properties("ForeColor") = RGB(0, 41, 121)
.Properties("Font").Value.Item("Name") = "Calibri"
.Properties("Font.Size").Value.Item("Size") = 10
.Properties("SpecialEffect") = fmSpecialEffectFlat
.Name = "frmQuestionsL1" ' ***ERROR OCCURS HERE***
End With
Many thanks in advance for your help!
Bookmarks