I have the following code:
Sub EmailWorkbookToCoreAccounts()
xlsmname = Range("A2").Value
Edate = Format(Now, "MM-DD-YYYY hhmm")
ActiveWorkbook.SaveAs Filename:="C:\Documents and Settings\All Users\Desktop\" & xlsmname & "_" & Format(Edate, "MM-DD-YYYY hhmm") & ".xlsm", FileFormat:=52, CreateBackup:=False
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 = "[email protected]"
.CC = ""
.BCC = ""
.Subject = xlsmname
.Body = ""
.Attachments.Add ActiveWorkbook.FullName
.Display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
The code first saves the workbook to the user's desktop then starts an email (via Outlook) with the workbook attached. It seems that this code works perfectly with Windows XP, but doesn't work with Windows 7 - any ideas on how to fix this?
Edit Post 7-19-12 3:19pm:
I should mention that in Windows 7 the macro will save the workbook to the desktop, start an email, but it doesn't attach the workbook to the email.
Bookmarks