I have a workbook in Excel that has multiple tabs. I have a macro that will save the active tab as a PDF and then email the PDF to the email address that is in cell AB1. The code works great if I run it for each tab individually. I would like to loop the macro to run for each tab in the workbook. Can anyone help me add the necessary code for the loop?
Here is the code that I am using.
Sub Individual_Scores()
ChDir "C:\Users\eenkey\Dropbox (RheoVest)\RheoVest's shared workspace\Zubie\Headquarters"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:\Users\eenkey\Dropbox (RheoVest)\RheoVest's shared workspace\Zubie\Headquarters\" & ActiveSheet.Name & ".pdf", OpenAfterPublish:=True
Dim OutLookApp As Object
Dim OutLookMailItem As Object
Dim myAttachments As Object
Set OutLookApp = CreateObject("OutLook.Application")
Set OutLookMailItem = OutLookApp.CreateItem(0)
Set myAttachments = OutLookMailItem.Attachments
With OutLookMailItem
.to = Range("AB1").Value
.Subject = ActiveSheet.Name & " Zubie Scores"
.Body = "Testing Save to PDF and Email."
myAttachments.Add "C:\Users\eenkey\Dropbox (RheoVest)\RheoVest's shared workspace\Zubie\Headquarters\" & ActiveSheet.Name & ".pdf"
.Send
End With
Set OutLookMailItem = Nothing
Set OutLookApp = Nothing
End Sub
Here is the code that I am using.
Sub Individual_Scores()
ChDir "C:\Users\eenkey\Dropbox (RheoVest)\RheoVest's shared workspace\Zubie\Headquarters"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:\Users\eenkey\Dropbox (RheoVest)\RheoVest's shared workspace\Zubie\Headquarters\" & ActiveSheet.Name & ".pdf", OpenAfterPublish:=True
Dim OutLookApp As Object
Dim OutLookMailItem As Object
Dim myAttachments As Object
Set OutLookApp = CreateObject("OutLook.Application")
Set OutLookMailItem = OutLookApp.CreateItem(0)
Set myAttachments = OutLookMailItem.Attachments
With OutLookMailItem
.to = Range("AB1").Value
.Subject = ActiveSheet.Name & " Zubie Scores"
.Body = "Testing Save to PDF and Email."
myAttachments.Add "C:\Users\eenkey\Dropbox (RheoVest)\RheoVest's shared workspace\Zubie\Headquarters\" & ActiveSheet.Name & ".pdf"
.Send
End With
Set OutLookMailItem = Nothing
Set OutLookApp = Nothing
End Sub