LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 126
Default Sending email routine, tweks needed

Hi,

Take a look at this code:
============
Public Sub mail()
Dim wb As Workbook
On Error GoTo ErrorHandler
'Copy to new workbook to be emailed
Sheets("Week to Date").Select
Range("A1:C22").Select
Application.CutCopyMode = False
Selection.Copy
Workbooks.Add
Selection.PasteSpecial Paste:=xlPasteColumnWidths,
Operation:=xlNone, _
SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteFormats, Operation:=xlNone,
_
SkipBlanks:=False, Transpose:=False
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False


'Sheets("Week to Date").Copy
Set wb = ActiveWorkbook
With wb
'.SaveAs Sheets("Week to Date").Name & ".Xls"
.SaveAs wb.Name & "eTracker.Xls"
.SendMail "", wb.Name
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
ErrorHandler:

End Sub
========
The idea is to add a workbook with new sheet, copy the format and
values *only* to the new sheet and email it.

Two things with this code:
- It works, but only once. if the code is run a second time then on
the line .SaveAs wb.Name & "eTracker.Xls" it jumps to ErrorHandler.
Obviosuly there is a problem, dont know what it is and how to solve.
(Yes I checked and there is no file with same name in the folder!)
I need help make sure than it doesnt happen.

- Is there a way to confirm that the email was sent?
If not how to go around to get some sort of confirmation?
The reason is that after information is deleted and cannot be
recovered so need to make sure an email was sent.

- What this does it opens an email message window from Outlook, which
is fine, and adds the file as an attachment.
I was wondering if it is possible "paste" the sheet in the message
body?

Thanks for all the help.
 
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
Sending a Spreadsheet as an Email Attachment vs. Imbedded in Email billbrandi Excel Discussion (Misc queries) 1 April 3rd 08 03:44 AM
Print routine needed for code pano Excel Worksheet Functions 3 February 11th 07 02:27 PM
Help needed with multi-sheet routine David Excel Programming 8 January 15th 07 02:53 AM
Error routine needed Jeff Wright[_2_] Excel Programming 1 April 21st 05 04:11 AM
Help needed with FIND routine. Matthew[_8_] Excel Programming 4 October 5th 03 11:50 PM


All times are GMT +1. The time now is 09:55 PM.

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

About Us

"It's about Microsoft Excel"