Problems with CoCreateInstance of Outlook Application object



Hello

I have imported the Outlook 9 files:

#import "C:\Program Files\Microsoft Office2k\Office\mso9.dll"
rename_namespace("Office"), named_guids
using namespace Office;
#import "C:\Program Files\Microsoft Office2k\Office\msoutl9.olb"
rename_namespace("Outlook"), named_guids, raw_interfaces_only
using namespace Outlook;

// my Outlook application object
CComPtr<Outlook::_Application> spApp;

Then if I do either:
hr=CoCreateInstance(CLSID_Application, NULL, CLSCTX_ALL, IID__Application,
(void**)&spApp);
or
hr = m_spApp.CoCreateInstance(CLSID_Application, NULL, CLSCTX_ALL);

I get hr of 0x80004002 which means No such interface supported. Why?

I have even seen code samples on the web doing exactly this. If I do
similar in VBA code it works OK.

Eg
Dim MyApp as Outlook.Application
Set MyApp = CreateObject("Outlook.Application")
This works.

Any help would be much appreciated.

Angus


.



Relevant Pages