I am trying to automatically send emails from a spreadsheet at certain times, but I want to avoid selecting sheet that has content I want to send.
Here I have what works if sheet "Rap_Zmiana_Trans" is active when macro runs. I want to achieve the same without selecting sheet.
***I know I can make selecting and going back to current sheet autamitiaclly but this will destroy the workflow.
Dim OutApp As Object
Set OutApp = OutlookApp()
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
ActiveSheet.Range("A1:Z56").Select
ActiveWorkbook.EnvelopeVisible = True
With Sheets("Rap_Zmiana_Trans").MailEnvelope
.Item.To = "aaa@.pl"
.Item.Subject = "Raport Transporty"
'.Introduction = "Raport Transporty"
.Item.Send
End With
Application.ScreenUpdating = True
Here I have what works if sheet "Rap_Zmiana_Trans" is active when macro runs. I want to achieve the same without selecting sheet.
***I know I can make selecting and going back to current sheet autamitiaclly but this will destroy the workflow.
Dim OutApp As Object
Set OutApp = OutlookApp()
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
ActiveSheet.Range("A1:Z56").Select
ActiveWorkbook.EnvelopeVisible = True
With Sheets("Rap_Zmiana_Trans").MailEnvelope
.Item.To = "aaa@.pl"
.Item.Subject = "Raport Transporty"
'.Introduction = "Raport Transporty"
.Item.Send
End With
Application.ScreenUpdating = True