I have an Excel sheet where I create an order list, then I have a button that exports the order list in to a new excel sheet, which works fine.
But I would also like to have a option that copies the order in the original document to a new workbook, then attaches that sheet to an e-mail but I don't want to save the file prior to attaching it to the e-mail.
This is my current code, partly taken from Attach Current Workbook into an Email Using Macros | MyExcelOnline
But I get an error, that the file name can't be found..
Any ways around this?
But I would also like to have a option that copies the order in the original document to a new workbook, then attaches that sheet to an e-mail but I don't want to save the file prior to attaching it to the e-mail.
This is my current code, partly taken from Attach Current Workbook into an Email Using Macros | MyExcelOnline
But I get an error, that the file name can't be found..
Any ways around this?
VBA Code:
Sub Export_Send()
Application.ScreenUpdating = False
Dim OutlookApp As Object
Dim OutlookMail As Object
Set OutlookApp = CreateObject("Outlook.Application")
Set OutlookMail = OutlookApp.CreateItem(0)
Sheets("Ordersheet").Select
Sheets("Ordersheet").Copy Before:=Sheets(4)
Sheets("Ordersheet (2)").Select
ActiveSheet.Shapes.Range(Array("Button 3")).Select
Selection.Delete
ActiveSheet.Shapes.Range(Array("Button 4")).Select
Selection.Delete
ActiveSheet.Shapes.Range(Array("Button 1")).Select
Selection.Delete
ActiveSheet.Shapes.Range(Array("Button 2")).Select
Selection.Delete
Range("C3").Select
Cells.Select
Range("C3").Activate
Selection.Copy
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
Sheets("Ordersheet (2)").Select
Sheets("Ordersheet (2)").Name = "OrderToExcel"
Range("D71").Select
Sheets("OrderToExcel").Select
Application.CutCopyMode = False
Sheets("OrderToExcel").Move
Sheets("OrderToExcel").Select
With OutlookMail
.To = "support@myexcelonline.com"
.Attachments.Add ActiveWorkbook.FullName
.Display
End With
Set OutlookMail = Nothing
Set OutlookApp = Nothing
End Sub