Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming VBA / March 2008

Tip: Looking for answers? Try searching our database.

Can Not Automate Outlook From Excel

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Peter - 22 Jan 2008 05:09 GMT
Outllook 2003 on XP Pro

I am trying to open Outlook and crate a message from Excel VBA module and I
am getting the following error

The Operation failed. - -2147287037: In RunExportProgram Function

(Every thing works fine if Outlook is already open, but not when it's
closed)
The same code works fine on other computers even when Outlook is closed.

Here's the code:

   Dim OutlookApp       As Object

   Set OutlookApp = CreateObject("Outlook.Application")
   Set Message = OutlookApp.Application.CreateItem(0)  ' <-- This is where
the error occurs

Thanks

Peter
Sue Mosher [MVP-Outlook] - 22 Jan 2008 13:41 GMT
The cause may be an anti-virus program on your computer that has a feature to block Outlook scripting. If so, the solution is to turn off the script blocking feature. You may need to contact technical support for your anti-virus program to find out how to do that.

I've also seen reports that setting the server parameter can resolve this problem in some situations:

   Set ol = CreateObject("Outlook.Applicaton", localhost)

Also, you can simplify your statement creating a new message to:

   Set Message = OutlookApp.CreateItem(0)

Signature

Sue Mosher, Outlook MVP
  Author of Microsoft Outlook 2007 Programming:
    Jumpstart for Power Users and Administrators
   http://www.outlookcode.com/article.aspx?id=54

> Outllook 2003 on XP Pro
>
[quoted text clipped - 18 lines]
>
> Peter
Peter - 22 Jan 2008 14:58 GMT
The cause may be an anti-virus program on your computer that has a feature
to block Outlook scripting. If so, the solution is to turn off the script
blocking feature. You may need to contact technical support for your
anti-virus program to find out how to do that.

I've also seen reports that setting the server parameter can resolve this
problem in some situations:

   Set ol = CreateObject("Outlook.Applicaton", localhost)

Also, you can simplify your statement creating a new message to:

   Set Message = OutlookApp.CreateItem(0)

Signature

Sue Mosher, Outlook MVP
  Author of Microsoft Outlook 2007 Programming:
    Jumpstart for Power Users and Administrators
   http://www.outlookcode.com/article.aspx?id=54

> Outllook 2003 on XP Pro
>
[quoted text clipped - 19 lines]
>
> Peter

I have not tried the Antivirus thing yet because I don't have access to the
specific computer at this time, but when try

Set ol = CreateObject("Outlook.Applicaton", "localhost")
or
Set ol = CreateObject("Outlook.Applicaton", "<actual-name.domain.com>")

I get the following error on a computer that Outlook does open by the code.

---------------------------
Microsoft Excel
---------------------------
Class not registered on local machine - 463: In RunExportProgram Function
---------------------------
OK
---------------------------
Peter - 22 Jan 2008 15:03 GMT
Never Mind - spelling error.

Sorry about that !!!

> The cause may be an anti-virus program on your computer that has a feature
> to block Outlook scripting. If so, the solution is to turn off the script
[quoted text clipped - 52 lines]
> OK
> ---------------------------
Peter - 01 Mar 2008 14:10 GMT
I have disabled the Anti Virus program and still getting the same error
message. (I've stopped or disabled as many programs as I could, but the
error persists).
What else can I check or try?

Thank You

>> The cause may be an anti-virus program on your computer that has a
>> feature to block Outlook scripting. If so, the solution is to turn off
[quoted text clipped - 52 lines]
>> OK
>> ---------------------------
Sue Mosher [MVP-Outlook] - 01 Mar 2008 18:38 GMT
Did you try the alternate version of the CreateObject expression? Does the expression OutApp Is Nothing return True? Does the VBA environment have a reference set to the Microsoft Outlook library?

Signature

Sue Mosher, Outlook MVP
  Author of Microsoft Outlook 2007 Programming:
    Jumpstart for Power Users and Administrators
   http://www.outlookcode.com/article.aspx?id=54

> I have disabled the Anti Virus program and still getting the same error
> message. (I've stopped or disabled as many programs as I could, but the
[quoted text clipped - 57 lines]
>>> OK
>>> ---------------------------
Peter - 02 Mar 2008 13:39 GMT
Here's the updated code:

   Dim OutlookApp       As Object
   Dim Message          As Object

   Set OutlookApp = CreateObject("Outlook.Application")
   Set Message = OutlookApp.CreateItem(0)       ' <== fails here

   Message.Display
''''

'OutlookApp Is Nothing' returns False

VBA environment does not set reference to Outlook library, because I am
using late binding. I have tried setting the reference and using early
binding code, but got the same error.
The same code works fine when Outlook is already running, but fails when
Outlook is not started.

I have found this this error description: -2147287037 (80030003) The path %1
could not be found.

But path to what? It can not be path to Outlook executable, because the
Outlook does load into memory after executing Set OutlookApp =
CreateObject("Outlook.Application") statement. but it disappears from memory
after Set Message = OutlookApp.CreateItem(0) statement.

Did you try the alternate version of the CreateObject expression? Does the
expression OutApp Is Nothing return True? Does the VBA environment have a
reference set to the Microsoft Outlook library?

Signature

Sue Mosher, Outlook MVP
  Author of Microsoft Outlook 2007 Programming:
    Jumpstart for Power Users and Administrators
   http://www.outlookcode.com/article.aspx?id=54

> I have disabled the Anti Virus program and still getting the same error
> message. (I've stopped or disabled as many programs as I could, but the
[quoted text clipped - 62 lines]
>>> OK
>>> ---------------------------
Sue Mosher [MVP-Outlook] - 02 Mar 2008 19:47 GMT
Try adding statements to log onto the desired mail profile:

   Set ns = OutlookApp.GetNamespace("MAPI")
   ns.Logon "name of profile

Signature

Sue Mosher, Outlook MVP
  Author of Microsoft Outlook 2007 Programming:
    Jumpstart for Power Users and Administrators
   http://www.outlookcode.com/article.aspx?id=54

> Here's the updated code:
>
[quoted text clipped - 93 lines]
>>>> OK
>>>> ---------------------------
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.