i have he following macro to create email in Outlook and attach several sheets
I get subscript out of range and the code below is highlighted
See full code below
It would be appreciated if someone could kindly amend my code
I get subscript out of range and the code below is highlighted
Code:
.Attachments.Add Environ("TMP") & "\" & ThisWorkbook.Sheets("Financial Data for BR1").Name & ".xlsx"
See full code below
Code:
Sub EmailSheets()
Dim Ztext As String
Dim Zsubject As String
'ThisWorkbook.Activate 'start in THIS workbook
Ztext = [bodytext] 'read in text from named cell
Sheets(Array("Statement of accounts", "Statistical Information")).Copy
With Range("A1:O150")
.Value = .Value
End With
With ActiveWorkbook
Application.DisplayAlerts = False
.SaveAs Environ("TMP") & "\" & ThisWorkbook.Sheets("Statement of Financial Position").Name & ".xlsx"
Application.DisplayAlerts = True
.Close (True)
End With
With CreateObject("Outlook.Application").CreateItem(0)
.To = Join(Application.Transpose(Sheets("index").Range("S1:S3").Value), ";")
.Subject = "Financial Info"
.Body = Ztext
.Attachments.Add Environ("TMP") & "\" & ThisWorkbook.Sheets("Financial Data for BR1").Name & ".xlsx"
.Display
End With
end Sub
It would be appreciated if someone could kindly amend my code