View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
Ron de Bruin Ron de Bruin is offline
external usenet poster
 
Posts: 11,123
Default E-mail macro - Field Validation

Try this


Sub Mail_ActiveSheet_Outlook()
'You must add a reference to the Microsoft outlook Library
Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Dim wb As Workbook
Dim strdate As String

If Application.WorksheetFunction.CountA(Range("A1,A3, A5")) = 3 Then

strdate = Format(Now, "dd-mm-yy h-mm-ss")
Application.ScreenUpdating = False

ActiveSheet.Copy
Set wb = ActiveWorkbook
With wb
.SaveAs "Part of " & ThisWorkbook.Name _
& " " & strdate & ".xls"
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
With OutMail
.To = "
.CC = ""
.BCC = ""
.Subject = "This is the Subject line"
.Body = "Hi there"
.Attachments.Add wb.FullName
'You can add other files also like this
'.Attachments.Add ("C:\test.txt")
.Send 'or use .Display
End With
.ChangeFileAccess xlReadOnly
Kill .FullName
.Close False
End With
Application.ScreenUpdating = True
Set OutMail = Nothing
Set OutApp = Nothing
Else
MsgBox "Sorry"
End If

End Sub


--
Regards Ron de Bruin
http://www.rondebruin.nl



"tqdinh22" wrote in message
...

Hi,

I tried the code you suggested however it now returns a message saying
"invalid outside procedure," I don't know if I am entering it wrong...I
am a beginner w/ VB self learning. Can you show how you would
incorporate it into my code above?

Thx


--
tqdinh22
------------------------------------------------------------------------
tqdinh22's Profile: http://www.excelforum.com/member.php...o&userid=36453
View this thread: http://www.excelforum.com/showthread...hreadid=573184