CreateObject ("Outlook.Application") no longer works in Office 2010

crackod93

Board Regular
Joined
Aug 9, 2007
Messages
71
Hi all,

wondering if anyone knows how to get this working, previously when using Office 2007 (Excel and Outlook), the piece of code below was working fine, however since being forced to upgrade to Office 2010, it no longer works.

Code is:

Set mobjOutlook = CreateObject("Outlook.Application")

Any ideas?

thanks,
Dave
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
In the VBE, Tools > References, make sure that Microsoft Outlook 14.0 Object Library is ticked.
 
Upvote 0
Hi, thanks for the quick reply, yes its already ticked but still doesnt work.

When executing the macro it gives: RunTime 429, ActiveX component cant create object

When selecting Debug, the row 'Set mobjOutlook = CreateObject("Outlook.Application") is highlighted in yellow

cheers
 
Upvote 0
This ran without error for me using Excel 2010

Code:
Sub atest()
Dim mobjOutlook As Object
Set mobjOutlook = CreateObject("Outlook.Application")
End Sub
 
Upvote 0
Hmm well this is very strange as this is the bit which the Debug highlights

The only thing which has changed is being upgraded from office 2007 to office 2010

Any ideas? It was working fine in the 2007 version and is still working on other people's machines with office 2007
 
Upvote 0
Is outlook open when you run the code?
 
Upvote 0
Ok. I'm out of ideas.

You could try Set mobjOutlook = New Outlook.Application (set a reference to the outlook first). Just to see if it makes any difference.

Lots of detailed info here:
http://support.microsoft.com/kb/828550

Another try would be to re-register excel as described here under Re-register Excel With Windows (There are two steps, first unregister then register):
http://www.cpearson.com/excel/StartupErrors.aspx The same command can be run for Outlook.exe. I've never had to do this before so no experience - perhaps wait to see if anyone else has any ideas. But googling this problem turns up more unanswered questions in similar threads -- seems to be a somewhat obscure problem.
 
Upvote 0
Simulating of CreateObject can be the workaround, I hope, try:
Rich (BB code):

' Based on Ron de Bruin's code of Example 1
' from link http://www.rondebruin.nl/mail/folder2/mail1.htm
Sub Mail_workbook_Outlook()

  Dim OutApp As Object, OutMail As Object
  Dim cmd As String, t As Single

  ' Try to GetObject
  On Error Resume Next
  Set OutApp = GetObject(, "Outlook.Application")
  If Err Then
    ' --> Simulate CreateObject("Outlook.Application")
    cmd = """" & Application.Path & "\OUTLOOK.EXE"""
    Shell cmd, vbHide
    t = Timer + 10  ' timeout = 10 seconds max
    While OutApp Is Nothing And Timer < t
      Set OutApp = GetObject(, "Outlook.Application")
    Wend
    ' <-- End of simulation
  End If
  Set OutMail = OutApp.CreateItem(0)

  With OutMail
    .To = "Please@DoNotMail.it"
    .CC = ""
    .BCC = ""
    .Subject = "This is the Subject line"
    .Body = "Hi there"
    .Attachments.Add ActiveWorkbook.FullName
    .Display   'or use .Send
  End With
  On Error GoTo 0

  Set OutMail = Nothing
  'OutApp.Quit
  Set OutApp = Nothing

End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,003
Messages
6,122,655
Members
449,091
Latest member
peppernaut

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top