Hi,
I was wondering if i could get some help here. I was trying to set up a form
in word document which is then saved as a template. This is my first time
that i have attempted to do this. Thus, really need your guidance on this.
So, i have created a form in the word document using "forms" toolbar. After
finishing with the design, i then saved it as a template .dot. However, what
i would like to do here is instead of getting the user to type values
directly into the fields set in the document after running the template file,
I would like a pop-up form that would appear immediately when opening the
tempate. So the user will have to fill out the provided empty fields in the
form. Also there is a button called "generate report" in the pop-up form. By
clicking on the button, all the values from the fields will be dumped nicely
into the fields in the word document. hope i haven't lost you so far.
The following is the code i have that gives me a run-time error '5941' - The
requested member of the collection does not exist.
' Insert student's firstname (if any).
If (txtFirstName <> "") Then
ThisDocument.FormFields("StudApplication").Result = txtFirstName
Else
ThisDocument.FormFields("StudApplication").Delete
End If
How do i solve this error? BTW, how do i get into design mode in the word
document? because all the controls in the form toolbar are greyed out or
disable.
Thank you for your help in advance
Doug Robbins - Word MVP - 15 Nov 2007 09:17 GMT
See the article "How to create a Userform" at:
http://word.mvps.org/FAQs/Userforms/CreateAUserForm.htm

Signature
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
> Hi,
>
[quoted text clipped - 35 lines]
>
> Thank you for your help in advance
Russ - 15 Nov 2007 19:05 GMT
Doug gave you the userform link.
I'll try to explain the error code.
Apparently when you run the code, you do not have a formfield with a name of
"StudApplication", so if you try to address it, specifically, as you are
doing in this code (even while testing for existence), the compiler
(mailman?) says 'no one at that address'.
So for some collections you must loop through all their elements first and
test with code like this pseudocode:
Dim aMember As Word.WhateverCollection
For each aMember of Activedocuments.WhateverCollections
If aMember.name like "StudApplication" then
...
Else
...
End If
Next aMember
Of course if you do already know that it exists then you can address it
specifically.
> Hi,
>
[quoted text clipped - 27 lines]
>
> Thank you for your help in advance

Signature
Russ
drsmN0SPAMikleAThotmailD0Tcom.INVALID