VBA objects in 2010

Asator

Board Regular
Joined
Apr 5, 2010
Messages
186
This works in 2003:
Code:
Dim xlApp As Object
Dim wrdApp as Object
dim objOL as Object
...code...
Set xlApp = New Excel.Application
Set wrdApp = New Word.Application
Set objOL = New Outlook.Application
...code...
Set xlApp = Nothing
Set wrdApp = Nothing
Set objOL = Nothing

In 2010, it bombs out on Set xlApp = New Excel.Application or Set objOL = New Outlook.Application

Did something change in COM that would break this? It seems to die on different objects on different machines. Is the registry hosed? Both the machines were upgraded from 2003.

Basically the code opens up instances of each application, does a bunch of stuff in the background, then closes them (or at least its supposed to).
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
Are the appropriate items reference in the VBE using Tools | References ?

Does this sequence cause the same probmem?

Code:
    Dim appWD As Word.Application
 
    Set appWD = CreateObject("Word.Application")
    appWD.Visible = True
 
    ...code...
 
    Set appWD = Nothing
 
Upvote 0
Yes.. all the references are enabled.. CreateObject fails too (that's actually what I had originally, then switched to what I have above after it started puking in 2010.

What's odd is, if I open a new instance excel (for example) before I run this, it'll run, error out, and there will be a second instance of excel.exe launched. If I then remove the "new" from the set xlapp line and run it again, it works fine. Very odd.
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,602
Messages
6,179,843
Members
452,948
Latest member
UsmanAli786

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