我有一段代码将当前文件附加到发往我们销售代表的电子邮件中,等于销售代表电子邮件。以及我们公司的订单电子邮件。
我没有将整个文档附加到此电子邮件,而是希望从文档中复制标签并将其粘贴到新文档中。然后只发送新文档(从而减少文件大小,并希望将其从.xlsm附件更改为.xls附件)。
If ShapesAfter > ShapesBefore Then
MsgBox "Please Repair Invalid Equipment Selection", , "Invalid Selections _
Have Been Made"
ElseIf ShapesAfter = ShapesBefore Then
Sheets("inputs").Select
Dim y As String
y = Cells(61, 5).Value
Sheets("config").Select
Application.Dialogs(xlDialogSendMail).Show "" & y & "; " & "orders@domainname.com"
答案 0 :(得分:3)
以上示例返回运行时' 9'错误。这是更正后的代码:
Dim wb As Workbook
Set wb = Workbooks.Add
ThisWorkbook.Sheets("inputs").Copy After:=wb.Sheets(1)
ThisWorkbook.Sheets("config").Copy After:=wb.Sheets(1)
wb.Application.Dialogs(xlDialogSendMail).Show "" & y & "; " & "orders@domainname.com"
Set wb = Nothing
"的ThisWorkbook&#34。必须在那里添加。
答案 1 :(得分:2)
创建一个新的工作簿对象并将工作表复制到该工作簿对象。示例如下。
Dim wb As Workbook
Set wb = Workbooks.Add
Sheets("inputs").Copy After:=wb.Sheets(1)
Sheets("config").Copy After:=wb.Sheets(1)
wb.Application.Dialogs(xlDialogSendMail).Show "" & y & "; " & "orders@domainname.com"
Set wb = Nothing