Hiya All,
I have spent hours looking over the net trying to get this to work but can't seem to figure it out. What I have is a daily meeting notes page that I fill in everyday in our meetings. This is on sheet 1. I have managed to work out how to convert this page to PDF then send out to a pre-specified list that was kept within the code. However, I have realised that it needs to be a dynamic list as people leave and new people start etc.
I have got the following to kinda work. My issue is that it stops at the third person, due to the gap. However, I would like to keep these gaps as they will get filled once we have filled all vacancies.
Any help would be greatly appreciated and many thanks in advance for anything you can suggest.
On the second sheet, I have the following setup:
[TABLE="class: grid, width: 500, align: left"]
<tbody>[TR]
[TD]Manager@hotmail.com[/TD]
[TD]Bob[/TD]
[TD]Manager[/TD]
[/TR]
[TR]
[TD]Clinicallead@hotmail.com[/TD]
[TD]Jane[/TD]
[TD]Clinical Lead[/TD]
[/TR]
[TR]
[TD]nurse1@hotmail.com[/TD]
[TD]Sarah[/TD]
[TD]Nurse 1[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]Nurse 2[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]Nurse 3[/TD]
[/TR]
[TR]
[TD]LeadHCA@hotmail.com[/TD]
[TD]Stefani[/TD]
[TD]Lead HCA[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]Senior HCA[/TD]
[/TR]
[TR]
[TD]me@hotmail.com[/TD]
[TD]Dipam[/TD]
[TD]Finance[/TD]
[/TR]
[TR]
[TD]hr@hotmail.com[/TD]
[TD]Tracy[/TD]
[TD]HR[/TD]
[/TR]
</tbody>[/TABLE]
Here is my code:
Cheers again
Dipam
I have spent hours looking over the net trying to get this to work but can't seem to figure it out. What I have is a daily meeting notes page that I fill in everyday in our meetings. This is on sheet 1. I have managed to work out how to convert this page to PDF then send out to a pre-specified list that was kept within the code. However, I have realised that it needs to be a dynamic list as people leave and new people start etc.
I have got the following to kinda work. My issue is that it stops at the third person, due to the gap. However, I would like to keep these gaps as they will get filled once we have filled all vacancies.
Any help would be greatly appreciated and many thanks in advance for anything you can suggest.
On the second sheet, I have the following setup:
[TABLE="class: grid, width: 500, align: left"]
<tbody>[TR]
[TD]Manager@hotmail.com[/TD]
[TD]Bob[/TD]
[TD]Manager[/TD]
[/TR]
[TR]
[TD]Clinicallead@hotmail.com[/TD]
[TD]Jane[/TD]
[TD]Clinical Lead[/TD]
[/TR]
[TR]
[TD]nurse1@hotmail.com[/TD]
[TD]Sarah[/TD]
[TD]Nurse 1[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]Nurse 2[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]Nurse 3[/TD]
[/TR]
[TR]
[TD]LeadHCA@hotmail.com[/TD]
[TD]Stefani[/TD]
[TD]Lead HCA[/TD]
[/TR]
[TR]
[TD][/TD]
[TD][/TD]
[TD]Senior HCA[/TD]
[/TR]
[TR]
[TD]me@hotmail.com[/TD]
[TD]Dipam[/TD]
[TD]Finance[/TD]
[/TR]
[TR]
[TD]hr@hotmail.com[/TD]
[TD]Tracy[/TD]
[TD]HR[/TD]
[/TR]
</tbody>[/TABLE]
Here is my code:
Code:
Sub Email()
'
Dim PDF As String
ChDir "C:\Meetings\"
strDate = Format(Date, "ddmmyy")
PDF_File = "Meeting " & strDate & ".pdf"
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=PDF_File, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, _
IgnorePrintAreas:=False, OpenAfterPublish:=False
Sheet2.Activate
Dim OutLookApp As Object
Dim OutLookMailItem As Object
Dim myAttachments As Object
Dim strTo$
Dim strToFinal
Dim i%
strTo = "": i = 1
Do
strTo = strTo & Cells(i, 1).Value & "; "
i = i + 1
Loop Until IsEmpty(Cells(i, 1))
strToFinal = Mid(strTo, 1, Len(strTo) - 2)
Set OutLookApp = CreateObject("Outlook.application")
Set OutLookMailItem = OutLookApp.CreateItem(0)
Set myAttachments = OutLookMailItem.Attachments
With OutLookMailItem
.To = strToFinal
.Subject = "Today's Meeting Notes"
.Body = "Hi All," & vbLf & vbLf _
& "Please find the notes from today's meeting" & vbLf & vbLf _
& "Regards" & vbLf & vbLf _
& "" & vbLf & vbLf _
& "" & vbLf _
& "Dipam" & vbLf _
& "Finance" & vbLf _
& "http://www.mywork.com/"
myAttachments.Add "C:\Meetings\" & PDF_File
.display
End With
Set OutLookMailItem = Nothing
Set OutLookApp = Nothing
Kill "C:\Meetings\" & PDF_File
Sheet1.Activate
End Sub
Cheers again
Dipam