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
 
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
 
Upvote 0

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
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!
 
Upvote 0
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).
 
Upvote 0
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!
 
Upvote 0
@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!
 
Upvote 0
not sure if this has been resolved, but I thought this might help:

Outlook.Application.ActiveInspector.WindowState = olMinimized

this allows you to minimalise the active Outlook window so perhaps incorporating it in your code could help you to get rid of the visual pollution...
 
Upvote 0

Forum statistics

Threads
1,223,236
Messages
6,170,917
Members
452,366
Latest member
TePunaBloke

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
Back
Top