Macro to email a spastic page to addresses in the workbook

Dave8899

New Member
Joined
Jan 17, 2019
Messages
32
Hi sorry if this is already on her but I've been looking for 3 days now and cant find the answer.

I have the following VBA that will send a email to the address in the workbook But i need it to only send one spastic sheet names Time.
as a new book single sheet or a PDf what ever works


Sub EmailAttachmentRecipients()


ActiveSheet.Unprotect Password:="123"




Dim objOutlook As Object
Dim objNameSpace As Object
Dim objInbox As Object
Dim objMailItem As Object
Set objOutlook = CreateObject("Outlook.Application")
Set objNameSpace = objOutlook.GetNamespace("MAPI")
Set objInbox = objNameSpace.Folders(1)
Set objMailItem = objOutlook.CreateItem(0)


Dim StrTo As String
Dim i As Integer
StrTo = ""
i = 1


With Worksheets("Email")
Do
StrTo = StrTo & .Cells(i, 1).Value & "; "
i = i + 1
Loop Until IsEmpty(.Cells(i, 1))
End With


StrTo = Mid(StrTo, 1, Len(StrTo) - 2)


With objMailItem
.To = StrTo
.CC = ""
.Subject = "Time sheet for " & Format(Sheets("Email").Range("n2")) & Format(Sheets("Email").Range("L2"))
.Body = _
"Hi," & Chr(10) & Chr(10) & _
"Please see attached Time sheet for the above individual" & Chr(10) & _
""
.Attachments.Add ActiveWorkbook.FullName
.Display
End With




Set objOutlook = Nothing
Set objNameSpace = Nothing
Set objInbox = Nothing
Set objMailItem = Nothing


ActiveSheet.Protect Password:="123"


End Sub
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.

Forum statistics

Threads
1,214,782
Messages
6,121,532
Members
449,037
Latest member
tmmotairi

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top