View Single Post
  #3  
Old May 12th, 2010, 05:41 AM posted to microsoft.public.word.mailmerge.fields
Graham Mayor
external usenet poster
 
Posts: 18,297
Default Can I reset a mail merge document ASK/REF fields instead of closing and reopening another copy ?

While I agree with Doug that the usual way forward is to save the document
as a template and create new documents each time from the template, given
that you are not saving the document and do not need to retain the data
after printing, you could simply update the fields in the document. The
macro used as an example at http://www.gmayor.com/installing_macro.htm will
do that.

I would also go along with Doug's suggestion to use instead a protected form
or a userform to gather the data rather than a sequence of ask fields.

If you want to reset form fields you can do that with the following macro

Sub ResetFormFields()
Dim bProtected As Boolean
Dim oFld As FormFields
Dim i As Long
Set oFld = ActiveDocument.FormFields
If ActiveDocument.ProtectionType wdNoProtection Then
bProtected = True
ActiveDocument.Unprotect Password:=""
End If
For i = 1 To oFld.Count
With oFld(i)
.Select
Select Case .Type
Case Is = wdFieldFormTextInput
oFld(i).Result = ""
Case Is = wdFieldFormDropDown
oFld(i).Result = oFld(i).DropDown.ListEntries(1).name
Case Is = wdFieldFormCheckBox
oFld(i).CheckBox.Value = False
End Select
End With
Next i
If bProtected = True Then
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, NoReset:=True, Password:=""
End If
oFld(1).Select
End Sub

and in the case of the userform - you can simply recall the userform. For
the basics, see Word MVP FAQ - Userforms
http://word.mvps.org/FAQs/Userforms.htm

for a more in depth explanation, see
http://gregmaxey.mvps.org/Create_and...a_UserForm.htm

--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org




"Wilson" wrote in message
...
I have a form.dot with a number of ASK then REF fields. The REF fields use
dates and data obtained via the ASK fields. A new copy of the form is
opened (form.doc) then once the form is completed it is printed and then
used again. Right now we have to actually close the form (the form and data
is not saved or reused) then open a new copy of the form to enter new data.
Sometimes we do this 20+ times for different customers, one after another.
Is there some way I can have a macro in the form which simply resets the
ASK/REF fields to blank then "re-opens" a new copy of the form. Or do I
have to actually close the copy I have open and get a new copy of the form
each time ? I am using Word XP.

thanks .. Wilson R.