PDA

View Full Version : Send Excel sheet as email attachment using worksheet data using Windows 2010.



ihenry
05-31-2021, 03:50 AM
Hi Can anyone help, I am trying to Send a completed Excel sheet as email attachment using worksheet data using Windows 2010. Thank you in advance

Logit
05-31-2021, 08:37 AM
Option Explicit

Sub Email_Worksheet_As_Workbook()
ActiveSheet.Copy
With ActiveWorkbook
'.Windows(1).Visible = False
Application.DisplayAlerts = False
.SaveAs Environ("TMP") & "\tmp.xlsx", FileFormat:=xlWorkbookDefault, ConflictResolution:=xlLocalSessionChanges
Application.DisplayAlerts = True
.Close (True)
End With

With CreateObject("Outlook.Application").CreateItem(0)
.To = "me@yahoo.com"
.Subject = "Worksheet: " & ActiveSheet.Name
.Body = ""
.Attachments.Add Environ("TMP") & "\tmp.xlsx"
.Display
'.send
End With
End Sub

ihenry
05-31-2021, 09:35 AM
Hi Logit

Thank you so much, the code worked fine, the only thing now is how do I create a buttom that sits on the main page of the spreadsheet so that is can be run without opening up the VBAProject.

Once again thank you.

Logit
05-31-2021, 09:45 AM
https://www.homeandlearn.org/add_a_button_to_a_spreadsheet.html

ihenry
05-31-2021, 10:02 AM
Hi Logit

Thank you so much, the code worked fine, the only thing now is how do I create a buttom that sits on the main page of the spreadsheet so that is can be run without opening up the VBAProject.

Once again thank you.

ihenry
05-31-2021, 10:04 AM
Hi Logit

Thats, me completed what I set out to do, thank you so much for your help with this one.

Everything is working perfectly.

Thank you

Best regards

Logit
05-31-2021, 12:43 PM
Glad to assist.