So after figuring out the proper way to fill ou word docs using form fields, I am trying to find the best way to make the script formfill 2 word docs at the same time, I'm using "Case" to select which word docs it fills out based on a combo box selection, currently I have it set to fill out one doc
Code:
Private Sub cmdPrint_Click()
Dim appWord As Word.Application
Dim CloseWord As String
Dim doc As Word.Document
Dim selinv As String
'Avoid error 429, when Word isn't open.
On Error Resume Next
Err.Clear
'Set appWord object variable to running instance of Word.
Set appWord = GetObject(, "Word.Application")
If Err.Number <> 0 Then
'If Word isn't open, create a new instance of Word.
Set appWord = New Word.Application
selinv = Me!cmbInv
End If
Select Case strinvsel
Case "Conv"
Set doc = appWord.Documents.Open("C:\Sys\Com\Letters\Letters\Letter1.doc", , True)
With doc
.FormFields("txtName").Result = Me!TXTAN
.FormFields("txtAddOne").Result = Me!txtAA1
.FormFields("txtAddTwo").Result = Me!txtAA2
.FormFields("txtBor").Result = Me!txtBN
.FormFields("txtPo").Result = Me!txtPN
.FormFields("txtInv").Result = Me!txtIN
.FormFields("txtn1").Result = Me!txtBA1
.FormFields("txtn2").Result = Me!txtBA2
.Visible = True
.Activate
End With
ActiveDocument.SaveAs FileName:="L:\Sys\Com\Letters\Letters" & strNewFolderName & "\" & Me!txtBN & "," & "LetterNew1.doc", _
FileFormat:=wdFormatDocument
doc.Quit
If both word docs have the same name in the formfields is there a way to run Letter1 and Letter2 and save them as LetterNew1 and LetterNew2 without rehashing this whole snippet.(there will be 5 "case" options when it's done and 2 letters per "case") So I am trying to simplify it a bit.