Can't invoke createobject("outlook.application") unless I use createobject("outlook.application","localhost")

Posted on 2006-03-31
Last Modified: 2008-01-09
I have a new laptop and am having a problem I didn't have previously.

Within a custom form I'm trying

Set oOutlook = createobject("outlook.application")

and it generates an exception.

If I change it to

Set oOutlook = createobject("outlook.application","localhost")

it works.

I've never had to do this before on other machines.

I get a similar problem with VB6. If I add in the Outlook 11 library and try

set oOutlook = new Outlook.application

I get an error

If I change it to

set oOutlook = createobject("outlook.application","localhost")

It works.

Question by:jasonkneen
    LVL 9

    Expert Comment

    by:Naveen Swamy
    LVL 44

    Expert Comment

    Hello jasonkneen,

    this could've to do with a script blocker in AV software which requires explicit direction [localhost in this case] to the on the caller of create object

    hope this helps a bit

    Author Comment

    I've solved this. The solution was to uninstall office then reinstall - repair did not work.

    I'm not sure what the exact problem but it sounds like Outlook wasn't registered properly as an application server. Invoking "word.application" worked but outlook wouldn't unless the "localhost" server was specified.

    Not only is my script problem solved but google desktop now shows outlook messages, something it didn't do before so as I thought - the two issues were linked.

    Anyway, solution is complete reinstall of office!

    LVL 44

    Expert Comment

    glad you solved it :)
    after reading your comment it looks like a registry issue indeed, would be interesting to kn ow when it started happening maybe an update or something
    LVL 44

    Expert Comment

    paq and refund

    Accepted Solution

    PAQed with points refunded (500)

    Community Support Moderator

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
    Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now