In another lifetime I put together the macro below and it works as intended. (if there is an email in a specific sell, set up an email with the PDF version of the tab). Now I want to change it to email the excel version of the tab. Any ideas on the changes? I attempted to just change the ".pdf" to ".xls" but it did not work.
'If there is a mail address in AK1 create the file name and the PDF
strFName = ActiveWorkbook.Name
strFName = Left(strFName, InStrRev(strFName, ".") - 1) & "_" & sh.Name & ".pdf"
sh.ExportAsFixedFormat Type:=xlTypePDF, FileName:= _
TempFilePath & strFName, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
'If publishing is OK create the mail
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
'Create message
On Error Resume Next
With OutMail
.to = sh.Range("AK1").Value 'Insert required address here ########
.CC = ""
.BCC = ""
.Subject = "Commission Statement for " & sh.Range("B3").Value
.Body = ""
.Attachments.Add TempFilePath & strFName
.Display 'Use only during debugging
'.Send 'Uncomment to send e-mail
End With
'If there is a mail address in AK1 create the file name and the PDF
strFName = ActiveWorkbook.Name
strFName = Left(strFName, InStrRev(strFName, ".") - 1) & "_" & sh.Name & ".pdf"
sh.ExportAsFixedFormat Type:=xlTypePDF, FileName:= _
TempFilePath & strFName, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
'If publishing is OK create the mail
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
'Create message
On Error Resume Next
With OutMail
.to = sh.Range("AK1").Value 'Insert required address here ########
.CC = ""
.BCC = ""
.Subject = "Commission Statement for " & sh.Range("B3").Value
.Body = ""
.Attachments.Add TempFilePath & strFName
.Display 'Use only during debugging
'.Send 'Uncomment to send e-mail
End With