Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 49
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 24
Default 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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
command in filter, then save as individual workbook and print out [email protected] Excel Programming 4 February 22nd 08 08:15 PM
Save workbook via Command Button???? Chris Watson[_5_] Excel Programming 3 March 23rd 06 10:11 AM
Can I Save WS Values Before Emailing Using Mailsend wallyb Excel Discussion (Misc queries) 0 January 13th 06 02:28 PM
Command Button to Save As Workbook... RPIJG[_13_] Excel Programming 1 May 12th 04 08:59 PM
save command bar into an excel workbook using vb José Ignacio Bella Excel Programming 4 November 25th 03 08:46 PM


All times are GMT +1. The time now is 02:14 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"