jackdandcoke
09-29-2008, 09:55 AM
so I have this code
Sub eMailActiveWorkbook()
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 = "Webathon Reporting"
.Body = "Here is the Report"
.To = "name@thing.com"
.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
Application.Quit
End Sub
That I want to use at the end of an Auto_Run macro that e-mails out a file. Unfortunately, if it e-mails out the file and this macro is the Auto_Open, it will simply open the file, update all the pivot tables then e-mail it to that person and quit again.
What I need is a modified part of this code that turns off the Auto_Open before it mails out the file. Does this make sense?
Sub eMailActiveWorkbook()
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 = "Webathon Reporting"
.Body = "Here is the Report"
.To = "name@thing.com"
.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
Application.Quit
End Sub
That I want to use at the end of an Auto_Run macro that e-mails out a file. Unfortunately, if it e-mails out the file and this macro is the Auto_Open, it will simply open the file, update all the pivot tables then e-mail it to that person and quit again.
What I need is a modified part of this code that turns off the Auto_Open before it mails out the file. Does this make sense?