Outlook.application startup differences Outlook 200 vs 2003 Please help ;-)

D

Dikbill

Hi there,

I'm creating a synchronisation program which wil synchronise
data between Outlook and our own database.
We want our program to work with Outlook 2000 and up.
The program is made with VB 2005 to communicate with a
standalone Outlook 2000/2003 Outlook client.

The problem I have is connecting with Outlook.
When the program starts, there can be 3 situations:

1. Outlook.exe isn't running
2. Outlook is running but invisible (Application.Explorers.Count=0)
3. Outlook is running visible


This is my startup code:

olApplication = New Outlook.Application
msgbox (olApplication.Version)

Now I discribe the above 3 situations from both Outlook 2000 and 2003

---Outlook 2003 situation 1-----------------------------------------------
Outlook is started but unvisible, that's not what I want.
The program starts with no errors, I can interact with Outlook.

---Outlook 2003 situation 2-----------------------------------------------
Outlook is started but unvisible, that's not what I want.
The program starts with no errors, I can interact with Outlook.
Every time when I start my program, a new instance of Outlook.exe
is started!! That's not what I want.

---Outlook 2003 situation 3-----------------------------------------------
Outlook not started again, that's good.
The program starts with no errors, I can interact with Outlook.
This is what I want!

---Outlook 2000 situation 1-----------------------------------------------
Outlook is started but unvisible, that's not what I want.
The program starts with no errors, I can interact with Outlook.

---Outlook 2000 situation 2-----------------------------------------------
Outlook isn't started, it will give the following error when it want's to
execute
the line msgbox (olApplication.Version)

System.Runtime.InteropServices.COMException was unhandled
ErrorCode=-2146788252
Message="Exception from HRESULT: 0x800A9C64"
Source="mscorlib"
StackTrace:
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags
invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32
culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags
bindingFlags, Binder binder, Object target, Object[] providedArgs,
ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at
Microsoft.VisualBasic.CompilerServices.VBBinder.InvokeMember(String name,
BindingFlags invokeAttr, Type objType, IReflect objIReflect, Object target,
Object[] args, String[] namedParameters)
at Microsoft.VisualBasic.CompilerServices.LateBinding.LateGet(Object
o, Type objType, String name, Object[] args, String[] paramnames, Boolean[]
CopyBack)
at
Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateGet(Object
Instance, Type Type, String MemberName, Object[] Arguments, String[]
ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack)
at Outlook_CRM_Sync.AGENDA_MAIN.Opstart() in
C:\TestDotNet\CRM_sync\Outlook_CRM_Sync\Outlook_CRM_Sync\AGENDA_MAIN.vb:line
41
at Outlook_CRM_Sync.AGENDA_MAIN.AGENDA_MAIN_Load(Object sender,
EventArgs e) in
C:\TestDotNet\CRM_sync\Outlook_CRM_Sync\Outlook_CRM_Sync\AGENDA_MAIN.vb:line
23
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&
m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd,
Int32 nCmdShow)
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason,
ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at Outlook_CRM_Sync.AGENDA_MAIN.Main() in
C:\TestDotNet\CRM_sync\Outlook_CRM_Sync\Outlook_CRM_Sync\AGENDA_MAIN.Designer.vb:line
2
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[]
args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

---Outlook 2000 situation 3-----------------------------------------------
Same as Outlook 2000 situation 2

What I am doing wrong????
Anyone??

Tx a lot,

Dikbill, The Netherlands
(e-mail address removed)
 
K

Ken Slovak - [MVP - Outlook]

If you want Outlook visible when you don't have a UI you can add an Explorer
to the Explorers collection. Get a MAPIFolder object (like Inbox for
example) and use that object in the Add method of the Explorers collection
object. Make sure in those cases that you logon to the NameSpace object.

Usually instead of New or CreateObject you would use GetObject to see first
if Outlook was running. Even if you do use New you can only have 1 instance
of Outlook running so it should attach to that instance. Then a check for
Explorers.Count tells you if there is/was a UI.




Dikbill said:
Hi there,

I'm creating a synchronisation program which wil synchronise
data between Outlook and our own database.
We want our program to work with Outlook 2000 and up.
The program is made with VB 2005 to communicate with a
standalone Outlook 2000/2003 Outlook client.

The problem I have is connecting with Outlook.
When the program starts, there can be 3 situations:

1. Outlook.exe isn't running
2. Outlook is running but invisible (Application.Explorers.Count=0)
3. Outlook is running visible


This is my startup code:

olApplication = New Outlook.Application
msgbox (olApplication.Version)

Now I discribe the above 3 situations from both Outlook 2000 and 2003

---Outlook 2003 situation 1-----------------------------------------------
Outlook is started but unvisible, that's not what I want.
The program starts with no errors, I can interact with Outlook.

---Outlook 2003 situation 2-----------------------------------------------
Outlook is started but unvisible, that's not what I want.
The program starts with no errors, I can interact with Outlook.
Every time when I start my program, a new instance of Outlook.exe
is started!! That's not what I want.

---Outlook 2003 situation 3-----------------------------------------------
Outlook not started again, that's good.
The program starts with no errors, I can interact with Outlook.
This is what I want!

---Outlook 2000 situation 1-----------------------------------------------
Outlook is started but unvisible, that's not what I want.
The program starts with no errors, I can interact with Outlook.

---Outlook 2000 situation 2-----------------------------------------------
Outlook isn't started, it will give the following error when it want's to
execute
the line msgbox (olApplication.Version)

System.Runtime.InteropServices.COMException was unhandled
ErrorCode=-2146788252
Message="Exception from HRESULT: 0x800A9C64"
Source="mscorlib"
StackTrace:
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags
invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32
culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags
bindingFlags, Binder binder, Object target, Object[] providedArgs,
ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at
Microsoft.VisualBasic.CompilerServices.VBBinder.InvokeMember(String name,
BindingFlags invokeAttr, Type objType, IReflect objIReflect, Object
target, Object[] args, String[] namedParameters)
at Microsoft.VisualBasic.CompilerServices.LateBinding.LateGet(Object
o, Type objType, String name, Object[] args, String[] paramnames,
Boolean[] CopyBack)
at
Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateGet(Object
Instance, Type Type, String MemberName, Object[] Arguments, String[]
ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack)
at Outlook_CRM_Sync.AGENDA_MAIN.Opstart() in
C:\TestDotNet\CRM_sync\Outlook_CRM_Sync\Outlook_CRM_Sync\AGENDA_MAIN.vb:line
41
at Outlook_CRM_Sync.AGENDA_MAIN.AGENDA_MAIN_Load(Object sender,
EventArgs e) in
C:\TestDotNet\CRM_sync\Outlook_CRM_Sync\Outlook_CRM_Sync\AGENDA_MAIN.vb:line
23
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean
fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message&
m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd,
Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd,
Int32 nCmdShow)
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at Outlook_CRM_Sync.AGENDA_MAIN.Main() in
C:\TestDotNet\CRM_sync\Outlook_CRM_Sync\Outlook_CRM_Sync\AGENDA_MAIN.Designer.vb:line
2
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[]
args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

---Outlook 2000 situation 3-----------------------------------------------
Same as Outlook 2000 situation 2

What I am doing wrong????
Anyone??

Tx a lot,

Dikbill, The Netherlands
(e-mail address removed)
 
D

Dikbill

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
(e-mail address removed)



Ken Slovak - said:
If you want Outlook visible when you don't have a UI you can add an
Explorer to the Explorers collection. Get a MAPIFolder object (like Inbox
for example) and use that object in the Add method of the Explorers
collection object. Make sure in those cases that you logon to the
NameSpace object.

Usually instead of New or CreateObject you would use GetObject to see
first if Outlook was running. Even if you do use New you can only have 1
instance of Outlook running so it should attach to that instance. Then a
check for Explorers.Count tells you if there is/was a UI.




Dikbill said:
Hi there,

I'm creating a synchronisation program which wil synchronise
data between Outlook and our own database.
We want our program to work with Outlook 2000 and up.
The program is made with VB 2005 to communicate with a
standalone Outlook 2000/2003 Outlook client.

The problem I have is connecting with Outlook.
When the program starts, there can be 3 situations:

1. Outlook.exe isn't running
2. Outlook is running but invisible (Application.Explorers.Count=0)
3. Outlook is running visible


This is my startup code:

olApplication = New Outlook.Application
msgbox (olApplication.Version)

Now I discribe the above 3 situations from both Outlook 2000 and 2003

---Outlook 2003 situation
1-----------------------------------------------
Outlook is started but unvisible, that's not what I want.
The program starts with no errors, I can interact with Outlook.

---Outlook 2003 situation
2-----------------------------------------------
Outlook is started but unvisible, that's not what I want.
The program starts with no errors, I can interact with Outlook.
Every time when I start my program, a new instance of Outlook.exe
is started!! That's not what I want.

---Outlook 2003 situation
3-----------------------------------------------
Outlook not started again, that's good.
The program starts with no errors, I can interact with Outlook.
This is what I want!

---Outlook 2000 situation
1-----------------------------------------------
Outlook is started but unvisible, that's not what I want.
The program starts with no errors, I can interact with Outlook.

---Outlook 2000 situation
2-----------------------------------------------
Outlook isn't started, it will give the following error when it want's to
execute
the line msgbox (olApplication.Version)

System.Runtime.InteropServices.COMException was unhandled
ErrorCode=-2146788252
Message="Exception from HRESULT: 0x800A9C64"
Source="mscorlib"
StackTrace:
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags
invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32
culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags
bindingFlags, Binder binder, Object target, Object[] providedArgs,
ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at
Microsoft.VisualBasic.CompilerServices.VBBinder.InvokeMember(String name,
BindingFlags invokeAttr, Type objType, IReflect objIReflect, Object
target, Object[] args, String[] namedParameters)
at
Microsoft.VisualBasic.CompilerServices.LateBinding.LateGet(Object o, Type
objType, String name, Object[] args, String[] paramnames, Boolean[]
CopyBack)
at
Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateGet(Object
Instance, Type Type, String MemberName, Object[] Arguments, String[]
ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack)
at Outlook_CRM_Sync.AGENDA_MAIN.Opstart() in
C:\TestDotNet\CRM_sync\Outlook_CRM_Sync\Outlook_CRM_Sync\AGENDA_MAIN.vb:line
41
at Outlook_CRM_Sync.AGENDA_MAIN.AGENDA_MAIN_Load(Object sender,
EventArgs e) in
C:\TestDotNet\CRM_sync\Outlook_CRM_Sync\Outlook_CRM_Sync\AGENDA_MAIN.vb:line
23
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean
fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr
hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef
hWnd, Int32 nCmdShow)
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at Outlook_CRM_Sync.AGENDA_MAIN.Main() in
C:\TestDotNet\CRM_sync\Outlook_CRM_Sync\Outlook_CRM_Sync\AGENDA_MAIN.Designer.vb:line
2
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[]
args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args)
at
Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

---Outlook 2000 situation
3-----------------------------------------------
Same as Outlook 2000 situation 2

What I am doing wrong????
Anyone??

Tx a lot,

Dikbill, The Netherlands
(e-mail address removed)
 
D

Dikbill

Ken,

Re-installing did'nt solve the problem!
Just for your information.

Dikbill, The Netherlands
(e-mail address removed)




Ken Slovak - said:
If you want Outlook visible when you don't have a UI you can add an
Explorer to the Explorers collection. Get a MAPIFolder object (like Inbox
for example) and use that object in the Add method of the Explorers
collection object. Make sure in those cases that you logon to the
NameSpace object.

Usually instead of New or CreateObject you would use GetObject to see
first if Outlook was running. Even if you do use New you can only have 1
instance of Outlook running so it should attach to that instance. Then a
check for Explorers.Count tells you if there is/was a UI.




Dikbill said:
Hi there,

I'm creating a synchronisation program which wil synchronise
data between Outlook and our own database.
We want our program to work with Outlook 2000 and up.
The program is made with VB 2005 to communicate with a
standalone Outlook 2000/2003 Outlook client.

The problem I have is connecting with Outlook.
When the program starts, there can be 3 situations:

1. Outlook.exe isn't running
2. Outlook is running but invisible (Application.Explorers.Count=0)
3. Outlook is running visible


This is my startup code:

olApplication = New Outlook.Application
msgbox (olApplication.Version)

Now I discribe the above 3 situations from both Outlook 2000 and 2003

---Outlook 2003 situation
1-----------------------------------------------
Outlook is started but unvisible, that's not what I want.
The program starts with no errors, I can interact with Outlook.

---Outlook 2003 situation
2-----------------------------------------------
Outlook is started but unvisible, that's not what I want.
The program starts with no errors, I can interact with Outlook.
Every time when I start my program, a new instance of Outlook.exe
is started!! That's not what I want.

---Outlook 2003 situation
3-----------------------------------------------
Outlook not started again, that's good.
The program starts with no errors, I can interact with Outlook.
This is what I want!

---Outlook 2000 situation
1-----------------------------------------------
Outlook is started but unvisible, that's not what I want.
The program starts with no errors, I can interact with Outlook.

---Outlook 2000 situation
2-----------------------------------------------
Outlook isn't started, it will give the following error when it want's to
execute
the line msgbox (olApplication.Version)

System.Runtime.InteropServices.COMException was unhandled
ErrorCode=-2146788252
Message="Exception from HRESULT: 0x800A9C64"
Source="mscorlib"
StackTrace:
at System.RuntimeType.InvokeDispMethod(String name, BindingFlags
invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32
culture, String[] namedParameters)
at System.RuntimeType.InvokeMember(String name, BindingFlags
bindingFlags, Binder binder, Object target, Object[] providedArgs,
ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
at
Microsoft.VisualBasic.CompilerServices.VBBinder.InvokeMember(String name,
BindingFlags invokeAttr, Type objType, IReflect objIReflect, Object
target, Object[] args, String[] namedParameters)
at
Microsoft.VisualBasic.CompilerServices.LateBinding.LateGet(Object o, Type
objType, String name, Object[] args, String[] paramnames, Boolean[]
CopyBack)
at
Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateGet(Object
Instance, Type Type, String MemberName, Object[] Arguments, String[]
ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack)
at Outlook_CRM_Sync.AGENDA_MAIN.Opstart() in
C:\TestDotNet\CRM_sync\Outlook_CRM_Sync\Outlook_CRM_Sync\AGENDA_MAIN.vb:line
41
at Outlook_CRM_Sync.AGENDA_MAIN.AGENDA_MAIN_Load(Object sender,
EventArgs e) in
C:\TestDotNet\CRM_sync\Outlook_CRM_Sync\Outlook_CRM_Sync\AGENDA_MAIN.vb:line
23
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean
fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at
System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr
hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef
hWnd, Int32 nCmdShow)
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32
reason, ApplicationContext context)
at
System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32
reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at Outlook_CRM_Sync.AGENDA_MAIN.Main() in
C:\TestDotNet\CRM_sync\Outlook_CRM_Sync\Outlook_CRM_Sync\AGENDA_MAIN.Designer.vb:line
2
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[]
args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence
assemblySecurity, String[] args)
at
Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

---Outlook 2000 situation
3-----------------------------------------------
Same as Outlook 2000 situation 2

What I am doing wrong????
Anyone??

Tx a lot,

Dikbill, The Netherlands
(e-mail address removed)
 
K

Ken Slovak - [MVP - Outlook]

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.
 
D

Dikbill

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
(e-mail address removed)
 
K

Ken Slovak - [MVP - Outlook]

Well, the first thing you have to do is figure out why Outlook is being
terminated. I'd have no idea why that's happening.

There are a number of ways to find the Outlook version, most involve
registry scanning. HKCR\Outlook.Application\CurVer is one of them. The
default value will be something like "Outlook.Application.11" for Outlook
2003, "Outlook.Application.10" for Outlook 2002, etc.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top