Hello,

I'm busy with a project in VBA for Word. At run-time I want dynamically build up my Form collection. Depending on the FormField (Bookmarks) in my document (Word) it has to genrate the number of Forms. I compare the name of the FormField with the name of the Form in the Component Collection (VBE.ActiveVBProject.Components).

Anyway I can import a Component by the following code but after that I don't know how to select the component and rename it and add controls to the Component (UserForm)

This is the code:

Dim objTemp As Object
Dim frm As UserForm
Dim nf As Boolean
Const kUserForm = 3
Dim strTemp As String

n1 = 40
n2 = 40
n3 = 40

For Each ff In ActiveDocument.FormFields
nf = True
For Each objTemp In VBE.ActiveVBProject.VBComponents
With objTemp
If .Type = kUserForm Then
If Left(.Name, 4) = Left(ff.Name, 4) Then
nf = False
strTemp = Left(ff.Name, 4)
End If
End If
If nf = True Then
VBE.ActiveVBProject.VBComponents.Import _
("\\Pc0010\data\Word\Sjabloon\Form1.frm")
''' here I want to select the form1.frm '''
''' and then rename it and Add Controls '''
End If
End With
Next objTemp
Set objTemp = Nothing
Next ff


I would be glag if anybody could help me.

Kind regards,
Chris