Test if Outlook is open in VBA
THYBOB
-
zero22 -
zero22 -
Hello,
I am currently developing a utility that should ultimately manage the Anomaly Reports and change requests for my company. I want to send an email with an attachment as soon as an anomaly report is recorded (I can do that part). My problem is that in order for my email to be sent, Outlook needs to be open. Hence my question: How can I check if Outlook is open?
Thank you in advance for your responses,
I am currently developing a utility that should ultimately manage the Anomaly Reports and change requests for my company. I want to send an email with an attachment as soon as an anomaly report is recorded (I can do that part). My problem is that in order for my email to be sent, Outlook needs to be open. Hence my question: How can I check if Outlook is open?
Thank you in advance for your responses,
Configuration: Windows 2000/Excel 2003
5 answers
-
Thank you, it works by slightly modifying your code. Thank you very much.
'
' Checking the opening of the messaging
'
Set Appli = CreateObject("Outlook.Application")
'
If Appli.Explorers.Count > 0 Then GoTo OutLookIsStarted
MsgBox "You need to start your messaging: Now!", vbExclamation, "Action to take..."
GoTo End
'
' We can start the recording
'
OutLookIsStarted: -
Hello,
I was actually looking to test the opening of Outlook, it was very useful, thank you. Similarly, I'm creating a database for handling complaints + anomaly reports, managing automatic email communication to the concerned parties about what they have completed in the process.
Instead of asking the user to open Outlook, you can just do a Call Shell("Outlook.exe", 1), but you probably already guessed that.
There you go, long live mutual support!
Rip -
Here is the test I practice:
Set appli_outlook = Outlook.Application If appli_outlook.Explorers.Count > 0 Then appli_outlook.SendOutlookMsg return_msg, SendTo, sCC, sBCC, Subject, BodyText, sAttachment Else MsgBox "error sending e_mail because Outlook not loaded" End If
-
-
Set appli_outlook = Outlook.Application
if appli_outlook.activewindow is nothing then
MsgBox "error sending e_mail because Outlook is not loaded"
end if
There you go