DebugGalpin
Board Regular
- Joined
- Jun 29, 2011
- Messages
- 175
Hi guys,
I have the below macro I am using to pdf a sheet and send in an email. The problem is when I close the new workbook I can't seem to get the option to save not to appear even with Application.DisplayAlerts =False.... Any idea would be greatly appreciated
Cheers
DAVE
Option Explicit
Sub EmailPDF()
Application.DisplayAlerts = False
Dim MyFileName, FilePath, Folder, s, t, FileName, Address, Subject, Body As String
FilePath = Range("FilePath")
Folder = Range("Folder")
FileName = Range("FileName")
Address = Range("Email")
Subject = Range("Subject")
Body = Range("Body")
s = FilePath & "\" & Folder
t = FilePath & "\" & Folder & "\" & FileName
If Len(Dir(s, vbDirectory)) = 0 Then
MkDir (s)
End If
Application.DisplayAlerts = False
ActiveWorkbook.Worksheets("Template CDS").Copy
ActiveWorkbook.ExportAsFixedFormat xlTypePDF, t & ".pdf"
Dim olApp As Outlook.Application 'MUST RERENCE MICROSOFT OUTLOOK 9/10/11/12 OBJECT LIBRARY.
Dim olMail As MailItem
Set olApp = New Outlook.Application
Set olMail = olApp.CreateItem(olMailItem)
With olMail
.To = Address
.CC = ""
.Subject = Subject
.Body = Body
.Attachments.Add t & ".pdf"
.Display
End With
Set olMail = Nothing
Set olApp = Nothing
Application.DisplayAlerts = False
ActiveWorkbook.Close False
End Sub
I have the below macro I am using to pdf a sheet and send in an email. The problem is when I close the new workbook I can't seem to get the option to save not to appear even with Application.DisplayAlerts =False.... Any idea would be greatly appreciated
Cheers
DAVE
Option Explicit
Sub EmailPDF()
Application.DisplayAlerts = False
Dim MyFileName, FilePath, Folder, s, t, FileName, Address, Subject, Body As String
FilePath = Range("FilePath")
Folder = Range("Folder")
FileName = Range("FileName")
Address = Range("Email")
Subject = Range("Subject")
Body = Range("Body")
s = FilePath & "\" & Folder
t = FilePath & "\" & Folder & "\" & FileName
If Len(Dir(s, vbDirectory)) = 0 Then
MkDir (s)
End If
Application.DisplayAlerts = False
ActiveWorkbook.Worksheets("Template CDS").Copy
ActiveWorkbook.ExportAsFixedFormat xlTypePDF, t & ".pdf"
Dim olApp As Outlook.Application 'MUST RERENCE MICROSOFT OUTLOOK 9/10/11/12 OBJECT LIBRARY.
Dim olMail As MailItem
Set olApp = New Outlook.Application
Set olMail = olApp.CreateItem(olMailItem)
With olMail
.To = Address
.CC = ""
.Subject = Subject
.Body = Body
.Attachments.Add t & ".pdf"
.Display
End With
Set olMail = Nothing
Set olApp = Nothing
Application.DisplayAlerts = False
ActiveWorkbook.Close False
End Sub