|
-
Apr 11th, 2000, 09:44 PM
#1
Thread Starter
New Member
Hello,
Can anybody tell me how to Add a UserForm to a project in VBA (Word)?
I'm making a wizzard for Word and I want to Add dynamically UserForms to a project, depending
on some variables.
I tried the following:
I can loop through my collection by the following code:
Dim objTemp As Object
Const kUserForm=3
For each objTemp in VBE.Activeproject.VBComponents
With objTemp
If .Type = kUserForm Then
...
End If
End With
Next objTemp
On the ... I want to Add a UserForm. But there is a problem.
The Method VBE.ActiveProject.Add has a bug. You can find it in on
the following webpage: http://support.microsoft.com/support.../Q172/2/44.asp
So I used the VBE.ActiveProject.Import Method by following code:
Set myComp = VBE.ActiveVBProject.VBComponents.Import _
("\\Pc0010\data\Word\Sjabloon\Form1.frm")
And this works!
But then there is the actual problem: how can I set the VBComponent With .Type kUserFrom
(so I know it's a UserForms) to a UserForms so that I can Add Controls, set the Caption e.g.???
I also tried the following but it was also dead-ended:
Dim glbl As vba.Global
Dim coll As vba.Collection
Set glbl = New vba.Global
Set coll = glbl.UserForms
For Each frm In usrfrms
If <condition>
...
End If
Next frm
To add a UserForms on the ... I searched for a method to Add a Userform, but I couldn't find it.
One person came with the following solution:
Quoted:"The problem is that you try to set an instance of a Userform to a VBComponent
(a design time object, not an instance of this userform).
I think the following change to your code will work:
...
load form1
set frm=from1
(Assuming the name of the form is form1)
You now have control over the instance of this UserForm."
I tried this but I couldn't load the form1. I guess it's because in
my application Word(VBA) is leading.
Please does anybody has suggestions????????????????????????????
Kind regards,
Chris Jonkheer
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|