It should, broadly speaking, be possible. Some rather poor code to get you
started - imagine you have c:\test\Doc1.doc open, have filled in a form,
then click a button connected to the CopyFormDataToAllDocs sub which should
copy values to doc2.doc and doc3.doc and leave them open.
You might of course need to consider any number of additional things, e.g.
a. error handling in general
b. dealing with different types of form field (this will cope with text
fields)
c. dealing with fields in different documents with the same names but
different types, or different lengths etc. etc.
Peter Jamieson
Sub CopyFormDataToAllDocs()
Call CopyFormDataToOneDoc(ActiveDocument, "c:\test\doc2.doc")
Call CopyFormDataToOneDoc(ActiveDocument, "c:\test\doc3.doc")
End Sub
Sub CopyFormDataToOneDoc(objSourceDocument As Word.Document, pathname As
String)
Dim objTargetDocument As Word.Document
Dim objSourceField As Word.FormField
Dim objTargetField As Word.FormField
Set objTargetDocument = Application.Documents.Open(pathname)
For Each objSourceField In objSourceDocument.FormFields
On Error GoTo NoSuchField
Set objTargetField = objTargetDocument.FormFields(objSourceField.Name)
MsgBox objSourceField.Name & ": " & objSourceField.Result
objTargetField.Result = objSourceField.Result
Set objTargetField = Nothing
NoSuchField:
Err.Clear
On Error GoTo 0
Next
Set objTargetDocument = Nothing
End Sub