Outlook 메시지 를 생성하기 위해 VBA 절차 를 만들었습니다 . 결과는 동일하지만 활성 통합 문서를 보내려고 할 때 Outlook과 Excel이 차단되지 않습니다 . 빠른 실행 도구 모음에 버튼을 넣고 XLSTART의 자동로드 모듈에서이 절차를 호출 할 수 있습니다 .
Sub SendActiveWorkbook()
'Create Outlook Message and add Active Workbook file to it
Dim temp_file_full_name As String
Dim folder As String
Dim base As String 'File name without extension
Dim ext As String
'Create temp copy of ActiveWorkbook
With ActiveWorkbook
folder = Environ$("temp") & "\"
'Workbook name
base = .Name
'If workbook did not saved on disk, it does not have extension
If InStr(base, ".") > 0 Then
ext = Split(base, ".")(UBound(Split(base, ".")))
base = left(base, Len(base) - Len(ext) - 1)
Else
Select Case .FileFormat
Case xlExcel8: ext = "xls"
Case xlOpenXMLWorkbook: ext = "xlsx"
Case xlOpenXMLWorkbookMacroEnabled: ext = "xlsm"
Case xlExcel12: ext = "xlsb"
Case Else: ext = "xlsx"
End Select
End If
temp_file_full_name = folder & base & "." & ext
.SaveCopyAs temp_file_full_name
End With
'Create Outlook message with attachment of temp file and display it
With CreateObject("Outlook.Application").CreateItem(0)
.Subject = base
.Attachments.Add temp_file_full_name
.Display
End With
'Delete temp file. We don't need it anymore
Kill temp_file_full_name
End Sub