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
왜이 코드가 "excelile"을 두 번 열어 Excel 중 하나가 읽기 전용입니까? Word에서 Excel 파일을 닫으려면 어떻게합니까? VBA에서MailMerge가 Excel 파일을 두 번 열리는 것처럼 보입니까?
감사합니다. 그러나 workbooks.close를 실행하는 방법 또는 Excel 매크로에서 Excel을 종료하는 방법 Word는 DDE를 통해 Excel을 열고 열어 둡니다. – Tom
DDE를 사용하면 병합 문서가 닫히면 Excel도 자동으로 닫힙니다. 이 작업을 수행하려면 병합 출력을 닫지 않아도됩니다. –