VBA Outlook Screen Updating

jalrs

Active Member
Joined
Apr 6, 2022
Messages
300
Office Version
  1. 365
Platform
  1. Windows
Hello forum experts,

As the subject suggests I'm having trouble with outlook screen updating. I would like to turn it off, meaning that every time I run the macro, the outlook doesn't pop up a new window. Instead, it should just keep running on the taskbar. I've tried with Application.ScreenUpdating method, but this fails to work.

Any help is greatly appreciated.

VBA Code:
Sub mailIsencao()

Dim OutApp As Object
Dim OutMail As Object
Dim ws1 As Worksheet, ws2 As Worksheet

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
Set ws1 = ThisWorkbook.Worksheets("Readme")
Set ws2 = ThisWorkbook.Worksheets("MACRO 4")

ws2.Activate

On Error Resume Next

Application.ScreenUpdating = False

    With OutMail
        .To = Cells(2, 2).Value
        .CC = Cells(2, 3).Value
        .Subject = Cells(2, 4).Value
        .Body = Cells(2, 7).Value
        .Display
        .Attachments.Add "C:\Users\joafrodrigue\Desktop\share\finaldocname\ST_Isenção.xlsx"
        
    End With
    On Error GoTo 0

Set OutMail = Nothing

ws1.Activate

Application.ScreenUpdating = True

End Sub

Thanks
 

Micron

Well-known Member
Joined
Jun 3, 2015
Messages
3,797
Office Version
  1. 365
Platform
  1. Windows
That error pretty much always means your code project is missing a reference. Check if you've referenced Outlook xx Object Library.
When you Dim oApp As Object you are using late binding - vba figures out what object to create when you set.
When you Dim oApp As Outlook.Application that is early binding and you definitely need the object library for that. I'd say you cannot use Inspector without the library reference because Inspector is specific to Outlook.

Also, I pasted my own variable from code (EmailItem variable). You have to use your own variable(s): OutMail
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.

jalrs

Active Member
Joined
Apr 6, 2022
Messages
300
Office Version
  1. 365
Platform
  1. Windows
That error pretty much always means your code project is missing a reference. Check if you've referenced Outlook xx Object Library.
When you Dim oApp As Object you are using late binding - vba figures out what object to create when you set.
When you Dim oApp As Outlook.Application that is early binding and you definitely need the object library for that. I'd say you cannot use Inspector without the library reference because Inspector is specific to Outlook.

Also, I pasted my own variable from code (EmailItem variable). You have to use your own variable(s): OutMail
Thanks for the reply Micron.

However as I'm new to VBA, I don't understand the concepts you are talking about. Apologies.
If you could provide an explanation on how to perform the things you have listed I'd more than happy to look through them. Otherwise, if you lack the time, or the will, since I'm new and this might take a while, I will suggest my boss that we use .Send method, even if mistakes could follow within the e-mail.

Thank you once again Micron!
 

Micron

Well-known Member
Joined
Jun 3, 2015
Messages
3,797
Office Version
  1. 365
Platform
  1. Windows
Whenever somebody uses a term or phrase you don't understand, try Googling it. More than likely the term or phrase will be close enough to get you the info you need, especially when it involves technical terms or jargon. See if this helps
"ms access how to set references vba"


I know that what I posted works so maybe don't throw in the towel yet as sending mail as/with mistakes is easy to prevent (to a point, of course).
 

jalrs

Active Member
Joined
Apr 6, 2022
Messages
300
Office Version
  1. 365
Platform
  1. Windows
Whenever somebody uses a term or phrase you don't understand, try Googling it. More than likely the term or phrase will be close enough to get you the info you need, especially when it involves technical terms or jargon. See if this helps
"ms access how to set references vba"


I know that what I posted works so maybe don't throw in the towel yet as sending mail as/with mistakes is easy to prevent (to a point, of course).
I will have a look and comeback to you.

Thanks for googling it for me. Since I wasn't familiar with the terms, I thought the task was huge, that's why I said what I said

Thanks again!
 

jalrs

Active Member
Joined
Apr 6, 2022
Messages
300
Office Version
  1. 365
Platform
  1. Windows
@Micron

Since I will reference to all e-mail details based on cell values, parametrized values, I'll change to .Send method.

Thanks for your time!
 

Micron

Well-known Member
Joined
Jun 3, 2015
Messages
3,797
Office Version
  1. 365
Platform
  1. Windows
You're welcome. Good luck with your project!
 

Forum statistics

Threads
1,176,594
Messages
5,903,942
Members
435,059
Latest member
grumpytrashpanda

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top