Hi all, my Microsoft Office 2016 recently installed some patches and my previous code no longer works
I created an email where I would paste a set print area in the Excxel into the body of an outlook email. Now when I run the code it says "Compile error: Sub or Function not defined" on the line that says "Call CreatePic". It just stopped working after the recent patching.
Any help will be much appreciated.
I created an email where I would paste a set print area in the Excxel into the body of an outlook email. Now when I run the code it says "Compile error: Sub or Function not defined" on the line that says "Call CreatePic". It just stopped working after the recent patching.
Any help will be much appreciated.
VBA Code:
Dim outMail As Object
Dim d1 As Date, d2 As Date, wf As WorksheetFunction
Set wf = Application.WorksheetFunction
d1 = Date
d2 = wf.WorkDay(d1, -1)
With Application
.EnableEvents = False
.ScreenUpdating = False
End With
Set OutApp = CreateObject("Outlook.Application")
Set outMail = OutApp.CreateItem(0)
On Error Resume Next
With outMail
.To = ""
.CC = ""
.BCC = ""
.Subject = "Margin as of " & Format(d2, "mmmm dd, yyyy")
.HTMLBody = "<span LANG=EN>" _
& "<p class=style2><span LANG=EN><font FACE=Arial SIZE=2>" _
& "Dear All,<br ><br >Please find below the margin level: " _
& "<br><br>"
Call createPic("DailyEmail", "MarginArea", "pnlImage")
TempFilePath = Environ$("temp") & "\"
.Attachments.Add TempFilePath & "pnlImage.png", olByValue, 0
.HTMLBody = .HTMLBody & _
"<img src='" & TempFilePath & "pnlImage.png'>" & _
"<br><br><br>Best Regards,<br></font></span>" & "<span LANG=EN><font FACE=Arial SIZE=2>" & Application.UserName
.Display
End With
file = TempFilePath & "pnlImage.png"
If FileExists(file) > 0 Then
SetAttr file, vbNormal
Kill file
End If
On Error GoTo 0
With Application
.EnableEvents = True
.ScreenUpdating = True
End With
Set outMail = Nothing
Set OutApp = Nothing
End Sub
Last edited by a moderator: