Ken,
Thnx for your quick response!
My example wasn't right, it's very hot here at the moment,
about 34 degrees Celcius at the moment, so ....
I have only one line in the catch and that is:
Dim olApplication as object = Nothing
Try
olApplication = GetObject(, "Outlook.Application")
Catch
olApplication = CreateObject("Outlook.Application")
End Try
I use the try catch, or I could use on error resume next,
code because if no Outlook.exe is running, I get the
error:
"Cannot create ActiveX component."
But I think the problem is that a new Outlook.exe is started
for a short moment and then is killed again by something,
not by me, and that the olApplication which is returned from
the GetObject call tries to connect with an Outlook.exe
instance which isn't there anymore.
Any suggestions, otherwise I hav e to trie something else, I
don't know what yet. It would be nice to know how to get
the current Oultook version before Outlook is started.
Do you have a solution for that?
Tnx again,
Dikbill, The Netherlands
"Ken Slovak - [MVP - Outlook]" schreef in bericht
...
Hmm. Normally I would expect GetObject used that way to not create a new
instance of Outlook but to return Nothing if no object was running. Then
I'd use CreateObject. I certainly would not use both New and CreateObject.
I'm not sure about that Try...Catch block. What you really want to do is
test for the OL object being Nothing after using GetObject and then use
CreateObject if needed. Then I'd test for the OL object not being Nothing
before trying to get the NameSpace object.
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm
"Dikbill" wrote in message
. ..
Ken,
Thnx again.
I've tried the 'GetObject' method, sorry for not mentioning that in my
question,
and that seems to work because when an Outlook.exe is running, that
instance of Outlook is put in the variable which I use. olApplication
If no Outlook.exe is running a new one will be started, invisible.
Dim olApplication as object = Nothing
Try
olApplication = GetObject(, "Outlook.Application")
Catch
olApplication = New Outlook.Application
olApplication = CreateObject("Outlook.Application")
End Try
But then when I want to do the next:
Dim olns as object = olApplication.getNamespace("MAPI")
Then I get the error
Exception from HRESULT: 0x800A9C64
Do you have a clue???
Right now I'm re-installing office 2000, because maybe something has
become corrupt or something.
Tx,
Dikbill, The Netherlands