Open Outlook from a macro

  • Thread starter Thread starter Corey
  • Start date Start date
C

Corey

I have a code to send(email) a range of a worksheet to an email addres on
the sheet.
But if Outlook is not opened it simply sits in the OUTBOX until Outlook is
opened.
Is ther a line i can add to open Outlook if Not already.
This way it Will send immediately ?

Corey...
 
Thanks for the reply,
But Ron's site is very helpful, yet does not assist me with the OPENING on
Outlook from a Macro.

Corey....
 
It should do.

To start Outlook, just test it and open it

On Error Resume Next
Set AppOL = GetObject(,"Outlook.Application")
If AppOL Is Nothing Then
Set AppOL = CreateObject("Outlook.Application")
If AppOL Is Nothing Then
MsgBox "Something's up"
Exit Sub
Else
AppOL.Visible = True
End If
End If


--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)
 
Thanks for the reply Bob.

Am I suppose to any more than to test the code you posted than to run it
from a macro?
It thinks but does nothing??


Corey....
 
I just gave you code to test whether Outlook was started, if not start it.

You would add this to some code to send the mail.

--
---
HTH

Bob

(change the xxxx to gmail if mailing direct)
 
This works for me:
Sub ShowOutlook()

Dim olApp As OutLook.Application
Dim olNs As NameSpace

On Error Resume Next
Set olApp = GetObject(, "Outlook.Application")

If Err.Number = 429 Then
Set olApp = CreateObject("Outlook.Application")
End If

On Error GoTo 0

Set olNs = olApp.GetNamespace("MAPI")

If olApp.ActiveExplorer Is Nothing Then
olApp.Explorers.Add _
(olNs.GetDefaultFolder(olFolderCalendar)).Activate
Else
Set olApp.ActiveExplorer.CurrentFolder = _
olNs.GetDefaultFolder(olFolderCalendar)
olApp.ActiveExplorer.Display
End If

Set olNs = Nothing
Set olApp = Nothing

End Sub

I found it at:
http://www.dicks-clicks.com/excel/olBinding.htm

Remember to activate the reference in the Visual Basic Editor, Tools >
References...
Happy Excelling!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top