I want to add an userform by code in my module code.
Sub AddAnUserForm()
Dim MyUserform As Object
Set MyUserform = ThisWorkbook.VBProject.VBComponents.Add(vbext_ct_MSForm)
End Sub
When i run this code, i get an error for the first time like:
Run-time error '1004':
"Access to the VB Project by programming is not safe"
Note:This is a translation because it was in my language. The sentence is
something like this.
Next time and other times i get an another error:
Run-time error '1004':
"Method 'VBProject' of object '_Workbook' failed"
Any Ideas? How can i create an Userform by Code?