Failure to create Session object

  • Thread starter Thread starter user
  • Start date Start date
U

user

I am having a problem of creating Session object
<i>
Dim k as MAPI.Session
Set k = CreateObject("MAPI.Session")
</i>

the error is: Run-time error '429': ActiveX component can't create object.


This is Outlook 2000 SP-3 on Win2K Professional. Before I started
installing my add-in, I could not find cdo.dll on the machine (How do I
find if CDO was installed?). My application has copied and refistered
cdo.dll (is this good for istallation if CDO was not installed?). I
went to Tools->References and added CDO1.21 library, so that the VB
engine does not complain about the declaration (Dim k as MAPI.Session).

Any help would be really appreciated since this problem has been on my
table (on and off) for over a month now ...

Regards All,
Pre
 
The only real way to correctly install CDO 1.21 would be to use the Windows
Installer in your code to do a demand installation if needed. Copying
CDO.DLL wouldn't be enough and you can't legally redistribute CDO anyway.

See the ItemsCB COM addin sample on the Resources page at www.microeye.com
for an example in VB6 of demand installing CDO 1.21.
 
Ken,

thank you very much for your reply. Would it not be better to run
Outlook installation and then add CDO? (if an option with my client)

I've looked at the code ... It checks if CDO is installed by trying to
create Session object ... Could there not be something else that would
prevent creating Session object? Just curious ...


Private Function IsCDOInstalled() As Boolean
On Error GoTo errorCDOInstalled
Dim testCDOObj As Object
Set testCDOObj = New MAPI.Session
IsCDOInstalled = True
Set testCDOObj = Nothing
Exit Function
errorCDOInstalled:
IsCDOInstalled = False
End Function


Regards,
Pre
 
Obviously the best way is to ensure that CDO is installed from the Office
installation either originally or by using the Change option in Add/Remove
Programs. The demand installation method is just a code equivalent of using
the Change option in Add/Remove Programs without the UI dialogs.

Certainly there can be many things that could prevent a Session object from
being created. More extensive code might check for the error message, look
for CDO.DLL in it's standard location (which would vary depending on which
version of Outlook was installed) and so on.
 
Back
Top