View Single Post
  #3  
Old December 20th 06, 04:57 PM posted to microsoft.public.outlook.program_vba
JKro
external usenet poster
 
Posts: 4
Default CreateItem - Operation Failed

Hi Eric,

Thank you so much for the advice.

On the PC in question, I opened up the Outlook VBA editor and it bombed on
the same line:

Set objMail = olApp.CreateItem(olMailItem)

I also checked to see if there were any disabled items but there were not.

How can I find out if something is blocking scripting?

Also, I have tested this code on some other pcs (about 10 altogeter). On 5
pcs, it works successfully on. On 2 pcs, I get the error that I described
above. And on 3 pcs, the email is created and displayed but when I close the
email, they get the following error:

Microsoft Office Outlook has encountered a problem and needs to close.
We are sorry for the inconvenience.

The strange thing is, if I open up outlook prior to executing this code, it
works fine on all pcs. I thought this code would open up an instance of
outlook so I would not have to have Outlook running at the time of execution
(and this is the case on those 5 pcs where it works successfully).

Am I missing something?




"Eric Legault [MVP - Outlook]" wrote:

Try again in the Outlook VBA editor on that PC to verify that Oultook can be
automated. Use both CreateObject for the Application object, and the
intrinsic Outlook.Application object.

Also check under Help | About | Disabled Items just to make sure that the
VBA Add-In isn't disabled.

These are just guesses, as I was going to finger an anti-virus app as well.
However, if scripting is blocked you will not be able to use CreateObject,
but explicit late-bound references to the Outlook Object Model should work.
If it does, something is blocking scripting.

--
Eric Legault (Outlook MVP, MCDBA, MCTS: Messaging & Collaboration)
Try Picture Attachments Wizard for Outlook:
http://www.collaborativeinnovations.ca
Blog: http://blogs.officezealot.com/legault/


"JKro" wrote:

I have some code in an access database module that displays an email to send:

Const olMailItem As Long = 0
Const olFormatPlain As Long = 1

Dim olApp As Object
Dim objMail As Object

Set olApp = CreateObject("Outlook.Application")
Set objMail = olApp.CreateItem(olMailItem)

With objMail
.to = strEmail
.Subject = strSubject
.Body = strMessage
.attachments.Add (strAttachmentLocation)
.Display
End With

Set objMail = Nothing
Set olApp = Nothing

This code works fine on several pcs. However on at least one of my pcs, it
does not. The following line:

Set objMail = olApp.CreateItem(olMailItem)

Produces a run-time error, Operation Failed.

All of the pcs are running Outlook 2003. The versions are slightly
different (successful pc: 11.5608.5606, unsuccessful pc: 11.5608.8107) but I
don't think its the version of outlook because alot of my successfull pcs
have slightly different versions.

I checked the virus scan software and it is not blocking any outlook
scripting.

I've been banging my head against a wall for 4 days now... I can't figure
out why this same code would fail on certain pcs (with no real clues as to
why.)

Any help would be greatly appreciated!


Ads