Doug -
Here's a code snippet. Some of this isn't relevant to the issue, but you
should have what you need in here.
Thanks again for your help,
Chris
************* Start of code snippet *************
'Start an Instance of Word, or grab an already-existing one
On Error Resume Next
Set WordApp = GetObject(, "Word.Application")
If Err Then
Err.Clear
Set WordApp = GetObject("", "Word.Application")
End If
'Supress merge warning message about data, otherwise document not opened as
merge mail document
WordApp.DisplayAlerts = wdAlertsAll
'Hide Word until merging is complete,
WordApp.Visible = False
WordApp.WindowState = wdWindowStateMinimize
'Open master (blank) document
WordApp.Documents.Open FileName:=MainDocument, ReadOnly:=True
'Determine the name used by Word for the Main Document
'so that it can be closed after the Merge is completed
MainDocument = StrRev(MainDocument)
n = InStr(MainDocument, "\")
MainDocument = StrRev(MainDocument)
If n > 0 Then
MainDocument = Right(MainDocument, n - 1)
End If
n = InStr(MainDocument, ".")
If n > 0 Then
MainDocument = Left(MainDocument, n - 1)
End If
'Insert documents to be included in package into master document
For n = 0 To lstDocuments.ListCount - 1
If lstDocuments.Selected(n) = True Then
WordApp.Selection.InsertFile FileName:=lstDocuments.List(n),
ConfirmConversions:=True
If Err Then
MsgBox "Unable to locate document: " & lstDocuments.List(n),
vbInformation
Err.Clear
End If
If n < lstDocuments.SelCount - 1 Then
'Now including section break at the end of each document per message board
post
'in attempt to retain individual document formatting
' WordApp.Selection.InsertBreak wdSectionBreakNextPage
End If
End If
Next
'Indicate that the merge is to a new document (rather than the printer)
WordApp.ActiveDocument.MailMerge.Destination = wdSendToNewDocument
If Err Then
MsgBox Err.Description
Err.Clear
Exit Sub
End If
'Perform the mail-merge
WordApp.ActiveDocument.MailMerge.Execute
If Err Then
MsgBox Err.Description
Err.Clear
Exit Sub
End If
'Close the master document
g.LocateWordWindow WordApp, MainDocument
WordApp.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
'Set focus to the window containing the merged document
g.LocateWordWindow WordApp, "Form Letters"
'View
If chkView.Value = 0 Then
WordApp.ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges
Else
WordApp.Visible = True
WordApp.WindowState = wdWindowStateMaximize
End If
'Release the WordApp Object, and Exit
WordApp.Exit
Set WordApp = Nothing
******** End of Code Snippet **********