neilp
Well-known Member
- Joined
- Jul 5, 2004
- Messages
- 529
- Office Version
- 365
- Platform
- Windows
Hi guys
I use the following macro to automatically save and send an active workbook via email
Sub eMailActiveWorkbook()
Dim NewName As String
NewName = Sheets("DECS").Range("C4") & " - " & Sheets("DECS").Range("J4")
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\neilp\Desktop\" & NewName & ".xls", FileFormat _
:=xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:= _
False, CreateBackup:=False
Application.DisplayAlerts = True
Dim OL As Object
Dim EmailItem As Object
Dim Wb As Workbook
Application.ScreenUpdating = False
Set OL = CreateObject("Outlook.Application")
Set EmailItem = OL.CreateItem(olMailItem)
Set Wb = ActiveWorkbook
Wb.Save
With EmailItem
.Subject = "Trolley sheet"
.Body = "" & vbCrLf & _
"" & vbCrLf & _
""
.To = "user@email.co.uk"
.Importance = olImportanceNormal 'Or olImprotanceHigh Or olImprotanceLow
.Attachments.Add Wb.FullName
.Send
End With
Application.ScreenUpdating = True
Set Wb = Nothing
Set OL = Nothing
Set EmailItem = Nothing
End Sub
It works great, but whilst sending, it flashes up a dialogue box saying that "excel is trying to send email, do you want to continue" Clicking yes allows the programme to continue sending. I would prefer the code to run without it asking for this confirmation. Is that at all possible?
Thanks
Neilp
I use the following macro to automatically save and send an active workbook via email
Sub eMailActiveWorkbook()
Dim NewName As String
NewName = Sheets("DECS").Range("C4") & " - " & Sheets("DECS").Range("J4")
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:= _
"C:\Documents and Settings\neilp\Desktop\" & NewName & ".xls", FileFormat _
:=xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:= _
False, CreateBackup:=False
Application.DisplayAlerts = True
Dim OL As Object
Dim EmailItem As Object
Dim Wb As Workbook
Application.ScreenUpdating = False
Set OL = CreateObject("Outlook.Application")
Set EmailItem = OL.CreateItem(olMailItem)
Set Wb = ActiveWorkbook
Wb.Save
With EmailItem
.Subject = "Trolley sheet"
.Body = "" & vbCrLf & _
"" & vbCrLf & _
""
.To = "user@email.co.uk"
.Importance = olImportanceNormal 'Or olImprotanceHigh Or olImprotanceLow
.Attachments.Add Wb.FullName
.Send
End With
Application.ScreenUpdating = True
Set Wb = Nothing
Set OL = Nothing
Set EmailItem = Nothing
End Sub
It works great, but whilst sending, it flashes up a dialogue box saying that "excel is trying to send email, do you want to continue" Clicking yes allows the programme to continue sending. I would prefer the code to run without it asking for this confirmation. Is that at all possible?
Thanks
Neilp