I have tried two of Ron's sample VBA codes in my excel file located on my
website. The first sample uses OutLook and the second code uses SendMail. I
tried both, but no email is created and sent. I have included the first code
on my previous response and I have included the second code below for review.
Can someone tell me what changes I need to make to the code.
I am running VISTA. The excel file is saved in office 2000 formate and I am
running on office 2007.
Thank you for any help you can give.
Larry
My e-mail is dietbook95@hotmail.
SAMPLE CODE:
Sub Mail_Sheets()
'Working in 97-2007
Dim wb As Workbook
Dim Shname As Variant
Dim Addr As Variant
Dim N As Integer
Dim TempFilePath As String
Dim TempFileName As String
Dim FileExtStr As String
Dim FileFormatNum As Long
Shname = Array("Sheet1", "Sheet1")
Addr = Array("(e-mail address removed)", "(e-mail address removed)")
If Val(Application.Version) >= 12 Then
'You run Excel 2007
FileExtStr = ".xlsm": FileFormatNum = 52
Else
'You run Excel 97-2003
FileExtStr = ".xls": FileFormatNum = -4143
End If
With Application
.ScreenUpdating = False
.EnableEvents = False
End With
TempFilePath = Environ$("temp") & "\"
'Create the new workbooks/Mail it/Delete it
For N = LBound(Shname) To UBound(Shname)
TempFileName = "Sheet " & Shname(N) & " " & Format(Now, "dd-mmm-yy
h-mm-ss")
ThisWorkbook.Sheets(Shname(N)).Copy
Set wb = ActiveWorkbook
With wb
.SaveAs TempFilePath & TempFileName & FileExtStr, FileFormatNum
On Error Resume Next
.SendMail Addr(N), _
"This is the Subject line"
On Error Resume Next
.Close SaveChanges:=False
End With
Kill TempFilePath & TempFileName & FileExtStr
Next N
With Application
.ScreenUpdating = True
.EnableEvents = True
End With
End Sub