picklechips
New Member
- Joined
- Jun 22, 2018
- Messages
- 21
Hi all,
I have a macro that creates multiple emails and copies a powerpoint slide into the body of each email using the "Getinspector.wordeditor" function.
Im now trying to resize (make bigger) the slide that gets pasted into each email body. Any help would be greatly appreciated!
Thanks!
Pickles
I have a macro that creates multiple emails and copies a powerpoint slide into the body of each email using the "Getinspector.wordeditor" function.
Im now trying to resize (make bigger) the slide that gets pasted into each email body. Any help would be greatly appreciated!
Thanks!
Pickles
Code:
Option ExplicitFunction 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
Dim wb As Workbook
Set wb = ThisWorkbook
'Ratesheet pdf attachment
MsgBox ("Select Ratesheet PDF")
Ratesheetpdf = Application.GetOpenFilename("PDF Files (*.pdf), *.pdf")
'ppt slide attachment
MsgBox ("Select Powerpoint Email body File")
Dim strFileName As String
strFileName = Application.GetOpenFilename( _
FileFilter:="PowerPoint Files (*.pptx), *.pptx", _
Title:="Open", _
ButtonText:="Open")
If strFileName = "False" Then Exit Sub
Dim pptApp As Object
Dim pptPres As Object
Dim pptSlide As Object
Set pptApp = CreateObject("PowerPoint.Application")
Set pptPres = pptApp.Presentations.Open(strFileName)
Set pptSlide = pptPres.Slides(1)
Set OutApp = CreateObject("Outlook.Application")
'Get the text that will go on the email subject
subj = Sheets(1).Range("b2")
wb.Activate
'add signature to email
SigName = Sheets(1).Range("c2")
SigString = Environ("appdata") & _
"\Microsoft\Signatures\" & SigName & ".htm"
If Dir(SigString) <> "" Then
Signature = GetBoiler(SigString)
Else
Signature = ""
End If
'Create email loop
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
.Display
.To = EmailTo
.CC = ""
.BCC = ""
.subject = subj
.Display
.body = ""
pptSlide.Copy
With .GetInspector.WordEditor
.Application.Selection.EndKey Unit:=6 'wdStory
.Application.Selection.TypeParagraph
.Application.Selection.Paste
End With
.htmlbody = .htmlbody & vbNewLine & vbNewLine & Signature
.Attachments.Add Ratesheetpdf
'.send
End With
Next i
On Error GoTo 0
pptPres.Close
pptApp.Quit
Set pptApp = Nothing
Set pptPres = Nothing
Set pptSlide = Nothing
Set OutMail = Nothing
Set OutApp = Nothing
End Sub