Hi i have an macro that saves a pdf and then emails out statements. But on conversion from 2013 to 365 it no longer works.
Could anyone have a look over the code and see if they can see what the issue is i.e. whats changed between versions that i need to update?
Any help appreciated.
Could anyone have a look over the code and see if they can see what the issue is i.e. whats changed between versions that i need to update?
Any help appreciated.
VBA Code:
Sub EMAILPDF()
Dim olApp As Object
Path = "S:\Sovini Corporate\Finance\Private\Treasury Services\Accounts Receivable\Emailed Statements\"
Number = ActiveSheet.Range("A2")
Customer = ActiveSheet.Range("C21")
strDate = Format(Date, "ddmmyy")
If i > 1 Then PDF_File = Left(PDF_File, i - 1)
PDF_File = Path & Number & " " & Customer & " " & strDate & ".pdf"
With ActiveSheet
.ExportAsFixedFormat Type:=xlTypePDF, Filename:=PDF_File, _
Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
End With
On Error Resume Next
Set olApp = GetObject(, "Outlook.Application")
If Err Then
Set olApp = CreateObject("Outlook.Application")
End If
On Error GoTo 0
With olApp.CreateItem(0)
.Subject = "Debtor Statement"
.SentonBehalfofName = ActiveSheet.Range("F16").Text
.To = ActiveSheet.Range("C2").Text
.Body = "Hi," & vbLf & vbLf _
& "Please find attached your latest statement. If you require copy invoices, please request them now and we will send over the copies prior to them falling due for payment." & vbLf & vbLf
.Attachments.Add PDF_File
.Save
.Display
End With
Set olApp = Nothing
End Sub
Last edited by a moderator: