You have to open, or create, the documents to process and process them separately e.g.
Private Sub CommandButton1_Click() Dim oRng As Range Dim oDoc1 As Document Dim oDoc2 As Document Dim oDoc3 As Document 'create (or open) the documents Set oDoc1 = Documents.Add("C:\Path\Template1.dotx") Set oDoc2 = Documents.Add("C:\Path\Template2.dotx") Set oDoc3 = Documents.Add("C:\Path\Template3.dotx") 'process each document 'fname If oDoc1.Bookmarks.Exists("fname") = True Then Set oRng = oDoc1.Bookmarks("fname").Range oRng.Text = TextBox1.value oDoc1.Bookmarks.Add "fname", oRng End If If oDoc2.Bookmarks.Exists("fname") = True Then Set oRng = oDoc2.Bookmarks("fname").Range oRng.Text = TextBox1.value oDoc2.Bookmarks.Add "fname", oRng End If If oDoc3.Bookmarks.Exists("fname") = True Then Set oRng = oDoc3.Bookmarks("fname").Range oRng.Text = TextBox1.value oDoc3.Bookmarks.Add "fname", oRng End If 'lname If oDoc1.Bookmarks.Exists("lname") = True Then Set oRng = oDoc1.Bookmarks("lname").Range oRng.Text = TextBox2.value oDoc1.Bookmarks.Add "lname", oRng End If If oDoc2.Bookmarks.Exists("lname") = True Then Set oRng = oDoc2.Bookmarks("lname").Range oRng.Text = TextBox2.value oDoc2.Bookmarks.Add "lname", oRng End If If oDoc3.Bookmarks.Exists("lname") = True Then Set oRng = oDoc3.Bookmarks("lname").Range oRng.Text = TextBox2.value oDoc3.Bookmarks.Add "lname", oRng End If 'address If oDoc1.Bookmarks.Exists("address") = True Then Set oRng = oDoc1.Bookmarks("address").Range oRng.Text = TextBox3.value oDoc1.Bookmarks.Add "address", oRng End If If oDoc2.Bookmarks.Exists("address") = True Then Set oRng = oDoc2.Bookmarks("address").Range oRng.Text = TextBox3.value oDoc2.Bookmarks.Add "address", oRng End If If oDoc3.Bookmarks.Exists("address") = True Then Set oRng = oDoc3.Bookmarks("address").Range oRng.Text = TextBox3.value oDoc3.Bookmarks.Add "address", oRng End If 'dob If oDoc1.Bookmarks.Exists("dob") = True Then Set oRng = oDoc1.Bookmarks("dob").Range oRng.Text = TextBox4.value oDoc1.Bookmarks.Add "dob", oRng End If If oDoc2.Bookmarks.Exists("dob") = True Then Set oRng = oDoc2.Bookmarks("dob").Range oRng.Text = TextBox4.value oDoc2.Bookmarks.Add "dob", oRng End If If oDoc3.Bookmarks.Exists("dob") = True Then Set oRng = oDoc3.Bookmarks("dob").Range oRng.Text = TextBox4.value oDoc3.Bookmarks.Add "dob", oRng End If 'amount If oDoc1.Bookmarks.Exists("amount") = True Then Set oRng = oDoc1.Bookmarks("amount").Range oRng.Text = TextBox5.value oDoc1.Bookmarks.Add "amount", oRng End If If oDoc2.Bookmarks.Exists("amount") = True Then Set oRng = oDoc2.Bookmarks("amount").Range oRng.Text = TextBox5.value oDoc2.Bookmarks.Add "amount", oRng End If If oDoc3.Bookmarks.Exists("amount") = True Then Set oRng = oDoc3.Bookmarks("amount").Range oRng.Text = TextBox5.value oDoc3.Bookmarks.Add "amount", oRng End If 'period If oDoc1.Bookmarks.Exists("period") = True Then Set oRng = oDoc1.Bookmarks("period").Range oRng.Text = TextBox6.value oDoc1.Bookmarks.Add "period", oRng End If If oDoc2.Bookmarks.Exists("period") = True Then Set oRng = oDoc2.Bookmarks("period").Range oRng.Text = TextBox6.value oDoc2.Bookmarks.Add "period", oRng End If If oDoc3.Bookmarks.Exists("period") = True Then Set oRng = oDoc3.Bookmarks("period").Range oRng.Text = TextBox6.value oDoc3.Bookmarks.Add "period", oRng End If Unload Me End Sub




Reply With Quote