Save command before emailing workbook
Is there anyway I can add to the code below to force them to save the
document before inserting the finalized workbook into an email? Without the Save command the workbook is emailed blank even though the user might have entered information. Thanks in advance Private Sub CommandButton1_Click() 'Working in 2000-2010 'This example send the last saved version of the Activeworkbook Dim OutApp As Object Dim OutMail As Object Set OutApp = CreateObject("Outlook.Application") Set OutMail = OutApp.CreateItem(0) On Error Resume Next With OutMail .To = "" .CC = "" .BCC = "" .Subject = "Employee Exit Form - Complete within 3 business days of receipt" .Attachments.Add ActiveWorkbook.FullName 'You can add other files also like this '.Attachments.Add '("C:\test.txt") .Display 'or use .Send End With On Error GoTo 0 Set OutMail = Nothing Set OutApp = Nothing End Sub |
Save command before emailing workbook
This might get you started:
Application.DisplayAlerts = False ActiveWorkbook.Save Application.DisplayAlerts = True "LRay67" wrote: Is there anyway I can add to the code below to force them to save the document before inserting the finalized workbook into an email? Without the Save command the workbook is emailed blank even though the user might have entered information. Thanks in advance Private Sub CommandButton1_Click() 'Working in 2000-2010 'This example send the last saved version of the Activeworkbook Dim OutApp As Object Dim OutMail As Object Set OutApp = CreateObject("Outlook.Application") Set OutMail = OutApp.CreateItem(0) On Error Resume Next With OutMail .To = "" .CC = "" .BCC = "" .Subject = "Employee Exit Form - Complete within 3 business days of receipt" .Attachments.Add ActiveWorkbook.FullName 'You can add other files also like this '.Attachments.Add '("C:\test.txt") .Display 'or use .Send End With On Error GoTo 0 Set OutMail = Nothing Set OutApp = Nothing End Sub |
All times are GMT +1. The time now is 01:20 AM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com