Lost text fields in merge

G

Guest

Is there a way to retain text form fields when merging a form to a new document? I want to open a document that contains checkboxes and text fields, merge it to a new document and protect it (per yesterday's post), then fill in the fields. The checkboxes aren't a problem, but the text form fields disappear when the merge is performed. I can't fill the document out first, because then I don't have the benefits of document protection (tabbing to fields, etc.). I can't find anything in Word help that addresses this problem, either. Suggestions?
 
C

Charles Kenyon

In the future, please continue in the same thread rather than starting a new
one. Even though I think I was the person who responded to you yesterday, I
don't remember much about your earlier question or my response. By posting
in the same thread, both would be available.

If, in doing a merge, you do not actually perform the merge but merely click
on the button on the mailmerge toolbar to display data you can go to the
record you want. This is what I meant by merging to the screen. Then protect
the document. You can then use your formfields.
--

Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://www.mvps.org/word which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
CGiannini said:
Is there a way to retain text form fields when merging a form to a new
document? I want to open a document that contains checkboxes and text
fields, merge it to a new document and protect it (per yesterday's post),
then fill in the fields. The checkboxes aren't a problem, but the text form
fields disappear when the merge is performed. I can't fill the document out
first, because then I don't have the benefits of document protection
(tabbing to fields, etc.). I can't find anything in Word help that
addresses this problem, either. Suggestions?
 
G

Guest

[ In the future, please continue in the same thread .....] Will do

Here's the problem in total: A merge form is linked to an Access database query. The form contains database fields that fill automatically, as well as checkboxes and text fields that have to be completed manually. The Access query pulls information for only one client record at a time (so the merge process you described, which I misunderstood, isn't applicable or necessary); the form is then merged to a new document, the checkboxes and form fields are completed, and the document is saved under the client name. (I'm not sure this is the best way to do this, but for now, it's what I've got.) I want the document protected when the user completes the checkboxes and form fields because it simplifies the process and prevents unintentional changes to the format. But if the original merge form is protected, the database fields fill and the checkboxes/form fields can be completed, but the merge function is disabled. If the form is merged to a new document, the checkboxes remain, but the text form fields disappear and can't be filled in unless protection is left off. Saving the document under a new name doesn't work: if it's opened later, it operates like the original form, opens and queries the database, etc. Pre-filling the form fields simply results in text in the new document that can't be changed. In short, the merge function seems to completely eliminate the use of text form fields in the new document. I'm hoping to find a way to override that
 
C

Charles Kenyon

I create a new document (not a merge result but a merge primary) from my
template. Then I have it display with the merge data inserted. Do _not_
merge to a new document; that is what knocks out your fields. Display the
document on the screen with the data inserted. I save this document with the
merge data and print it.

To make the document permanent, I have a macro I use that disconnects the
merge from the data source so that the resulting document is no longer a
merge document at all. Merge fields are replaced by their results. This will
not change formfields at all. I put it on a custom button on my mailmerge
toolbar. If you want me to post the macro here, I will.
--

Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://www.mvps.org/word which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.

CGiannini said:
[ In the future, please continue in the same thread .....] Will do.

Here's the problem in total: A merge form is linked to an Access database
query. The form contains database fields that fill automatically, as well
as checkboxes and text fields that have to be completed manually. The
Access query pulls information for only one client record at a time (so the
merge process you described, which I misunderstood, isn't applicable or
necessary); the form is then merged to a new document, the checkboxes and
form fields are completed, and the document is saved under the client name.
(I'm not sure this is the best way to do this, but for now, it's what I've
got.) I want the document protected when the user completes the checkboxes
and form fields because it simplifies the process and prevents unintentional
changes to the format. But if the original merge form is protected, the
database fields fill and the checkboxes/form fields can be completed, but
the merge function is disabled. If the form is merged to a new document,
the checkboxes remain, but the text form fields disappear and can't be
filled in unless protection is left off. Saving the document under a new
name doesn't work: if it's opened later, it operates like the original form,
opens and queries the database, etc. Pre-filling the form fields simply
results in text in the new document that can't be changed. In short, the
merge function seems to completely eliminate the use of text form fields in
the new document. I'm hoping to find a way to override that.
 
G

Guest

If you're willing to share your work, I'd really appreciate it - would save me the time. Many thanks.
 
C

Charles Kenyon

Here they are. I hope they are self-explanatory because it has been a year
and a half since I looked at them. They work for me in Word 2000-2003.
Haven't tested in Word 97.

Sub UnmergeThis()
' Written 29 August 2002 by Charles Kyle Kenyon
' Updated 23 September 2002 to attach normal.dot
' Remove merge codes from document, remove from merge status
'
' Test for template - in template only disconnect from merge but leave
merge fields active
'
On Error Resume Next
If ActiveDocument.Type = wdTypeTemplate Then
'
' Test for merge document - do not run if not merge document
'
If MergeTest() = False Then ' private function call
Exit Sub
End If
'
' Disconnect template from merge data
ActiveDocument.MailMerge.MainDocumentType = wdNotAMergeDocument
Application.CommandBars("MergeK").Visible = False
Exit Sub
End If
'
' Test for merge document - do not run if not merge document
'
If MergeTest() = False Then
Exit Sub
End If
'
Dim oField As Field
Dim vMsgBoxResponse As Variant
Dim sUserTemplates As String
'
' Double check with user because permanent operation
'
vMsgBoxResponse = MsgBox(Prompt:= _
"This will disconnect this document from the merge file." _
& vbCrLf & "This cannot be undone." & vbCrLf & vbCrLf _
& "Continue?", Buttons:= _
vbQuestion + vbYesNo + vbDefaultButton1, _
Title:="Continue?")
If vMsgBoxResponse <> vbYes Then
MsgBox Prompt:="No changes made to document.", _
Title:="Merge connection still active."
Exit Sub
End If
'
' OK to continue
'
Application.ScreenUpdating = False
'
For Each oField In ActiveDocument.Fields
If oField.Type = wdFieldMergeField Then
oField.Unlink
End If
Next oField
'
ActiveDocument.MailMerge.MainDocumentType = wdNotAMergeDocument
'
' Disconnect from template - attach normal.dot
'
sUserTemplates =
Application.Options.DefaultFilePath(wdUserTemplatesPath)
If Right(sUserTemplates, 1) <> "\" Then
sUserTemplates = sUserTemplates & "\"
End If
' sUserTemplates =
Application.Options.DefaultFilePath(wdUserTemplatesPath) & "\"
With ActiveDocument
.UpdateStylesOnOpen = False
.AttachedTemplate = sUserTemplates & "Normal.dot"
End With
Application.ScreenUpdating = True
Application.ScreenRefresh
'
End Sub

Private Function MergeTest() As Boolean
'
' Test for merge document - returns as true/false
' and displays message box if not merge document
'
If ActiveDocument.MailMerge.MainDocumentType = wdNotAMergeDocument Then
MsgBox "This is not a merge document."
MergeTest = False
Else
MergeTest = True
End If
End Function

It attaches the normal.dot template so that reopening the document won't
call up the datafile. The MergeTest function is just to kick you out of the
procedure if you are not in a merge document. There are comments in the code
(as well as left-over snippets commented out).


--

Charles Kenyon

Word New User FAQ & Web Directory: http://addbalance.com/word

Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide

See also the MVP FAQ: http://www.mvps.org/word which is awesome!
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.

CGiannini said:
If you're willing to share your work, I'd really appreciate it - would
save me the time. Many thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top