在Excel中使用数组VBA邮件表
-
使用SheetsArray创建一个新的工作簿。
-
在邮寄之前保存工作簿。
-
发送后从硬盘中删除文件。
Sub Mail_SheetsArray() Dim strDate As String Sheets(Array("Sheet1", "Sheet3")).Copy strDate = Format(Date, "dd-mm-yy") & " " & Format(Time, "h-mm-ss") ActiveWorkbook.SaveAs "Part of " & ThisWorkbook.Name _ & " " & strDate & ".xls" ActiveWorkbook.SendMail "[email protected]", _ "This is the Subject line" ActiveWorkbook.ChangeFileAccess xlReadOnly Kill ActiveWorkbook.FullName ActiveWorkbook.Close False End Sub