With ActiveDocument.MailMerge
.MainDocumentType = wdCatalog
.OpenDataSource Name:=excelfile, _
Connection:="Entire spreadsheet", SubType:=8, ReadOnly:=True
''# Range = Selection.Range
.Destination = wdSendToNewDocument
.Execute
End With ''# Activedocument
DDETerminateAll
Why does this code open “excelfile” twice to excel, one of these is readonly. How can I close these Excel files from Word?
Workbooks can be closed with this VBA code
Workbooks("BOOK1.XLS").CloseYou can add this to the end, so that no prompts to save are displayed if the file has been updated and not saved.
Excel can be closed via VBA with if called from within Excel.
If called from outside Excel, you will need to set a reference to Excel and then close it.
You need to ensure that all Workbooks are closed or saved, otherwise Excel will prompt the user to save