picklechips
New Member
- Joined
- Jun 22, 2018
- Messages
- 21
Hi all,
Im trying to create a VBA that inserts a powerpoint slide into the body of an email. Not sure if thats even possible...
If possible, it would open a prompt to me select the powerpoint file (using Application.GetOpenFilename maybe), then the macro would copy only the first powerpoint slide and paste it into the email body.
Below is the code I have so far which works in creating the email (creates multiple emails from loop if more than 100 email addresses are on my address list), only thing left is adding the one slide from a powerpoint file to the email body.
Thanks in advance!
Pickles
Im trying to create a VBA that inserts a powerpoint slide into the body of an email. Not sure if thats even possible...
If possible, it would open a prompt to me select the powerpoint file (using Application.GetOpenFilename maybe), then the macro would copy only the first powerpoint slide and paste it into the email body.
Below is the code I have so far which works in creating the email (creates multiple emails from loop if more than 100 email addresses are on my address list), only thing left is adding the one slide from a powerpoint file to the email body.
Thanks in advance!
Pickles
Code:
Option Explicit
Function GetBoiler(ByVal sFile As String) As String
Dim fso As Object, ts As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Set ts = fso.GetFile(sFile).OpenAsTextStream(1, -2)
GetBoiler = ts.readall
ts.Close
End Function
Sub Emailtest()
Dim SigString As String
Dim SigName As String
Dim Signature As String
Dim OutApp As Object
Dim OutMail As Object
Dim EmailTo As String
Dim Ratesheetpdf As Variant
Dim subj As String
Dim body As String
Dim LastRw As Long
Dim i As Integer
Ratesheetpdf = Application.GetOpenFilename("PDF Files (*.pdf), *.pdf")
Set OutApp = CreateObject("Outlook.Application")
'Get the text that will go on the subject
subj = Sheets(1).Range("b2")
'Get the text that will go on the body
body = ActiveWorkbook.Sheets(1).Range("c2")
'add signature
SigName = Sheets(1).Range("d2")
SigString = Environ("appdata") & _
"\Microsoft\Signatures\" & SigName & ".htm"
MsgBox SigString
If Dir(SigString) <> "" Then
Signature = GetBoiler(SigString)
Else
Signature = ""
End If
LastRw = Range("A" & Rows.Count).End(xlUp).Row
For i = 2 To LastRw Step 100
EmailTo = Join(Application.Transpose(Sheets(1).Range("A" & i & ":A" & WorksheetFunction.Min(i + 99, LastRw)).Value), ";")
Set OutMail = OutApp.CreateItem(0)
With OutMail
.To = EmailTo
.CC = ""
.BCC = ""
.subject = subj
'.body = body
.htmlbody = body & vbNewLine & vbNewLine & Signature
.Attachments.Add Ratesheetpdf
.Display
'.send
End With
Next i
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub