Quantcast
Channel: Active questions tagged excel - Stack Overflow
Viewing all articles
Browse latest Browse all 88835

Is there a way to prevent Outlook from asking about whether or not to save changes after opening it with Excel VBA?

$
0
0

The following Excel 2016 VBA code does open Outlook:

Sub mail()
    Dim objOutlook As Object
    Dim objMail As Object

    Set objOutlook = CreateObject("Outlook.Application")
    Set objMail = objOutlook.CreateItem(0)

    With objMail
       .To = "Yourname@Yourdomain.com"
       .Subject = "My Subject"
       .Body = "My message." 
       .Display        'This creates and opens the Email. The user has to manually click the send button in Outlook afterwards
    End With

End Sub

Now, the user has the valid option to immediately close Outlook.
However in this case, Outlook opens a pop-up window about whether or not to save changes.

Is there a way to prevent Outlook from opening this pop-up alert window by some Excel VBA code?


Viewing all articles
Browse latest Browse all 88835


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>