VBA learner ITG
Active Member
- Joined
- Apr 18, 2017
- Messages
- 272
- Office Version
- 365
- Platform
- Windows
- MacOS
hi all,
Can I please get your assistance. I have searched various forums and work arounds to try and resolve my issue to no avail.
The below code was working on my mac fine and now its generating an error ON THE BELOW LINE OF CODE.
The below is the master code!
Can I please get your assistance. I have searched various forums and work arounds to try and resolve my issue to no avail.
The below code was working on my mac fine and now its generating an error ON THE BELOW LINE OF CODE.
Code:
Set OutApp = CreateObject("Outlook.Application")
The below is the master code!
Code:
Sub Mail_workbook_Outlook_MASTER()
'Working in Excel 2000-2016
'This example send the last saved version of the Activeworkbook
'For Tips see: http://www.rondebruin.nl/win/winmail/Outlook/tips.htm
Dim OutApp As Object
Dim OutMail As Object
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.to = "zackcarter@itg.co.uk"
.CC = ""
.BCC = ""
.Subject = "This is the Subject line"
.Body = "Hi there"
.Attachments.Add SaveAsXLSX(ActiveWorkbook)
.Send 'or use .Display
End With
On Error GoTo 0
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
Function SaveAsXLSX(wb As Workbook) As String
wb.Sheets(Array("OUTPUT", "Additions")).Copy
With ActiveWorkbook
.SaveAs Replace(wb.FullName, "xlsm", "xlsx"), FileFormat:=51
SaveAsXLSX = .FullName
.Close SaveChanges:=False
End With
End Function