Commandbar

  • Thread starter Thread starter Sokrat Saydahmat
  • Start date Start date
S

Sokrat Saydahmat

Hi,

I have an outlook addin working perfectly in windows 2000 and outlook 2003.
Reccently I got a new pc installed with XP and outlook 2003, in this new pc
the code that supposed create commandbar and menuitems are failed.

Is this a window/outlook security issue?
 
It shouldn't be, depending on what your code looks like. My command bars
have no problems being created in any version of Outlook from 2000 to 2003.
Show the code you are using to create your command bar.
 
Is that mean XP requires diffirent coding? Same addin works in Windows 2000
and other XP pcs. There is only one of them having problem.

Public Sub OnConnection(ByVal application As Object, ByVal connectMode As
Extensibility.ext_ConnectMode, ByVal addInInst As Object, ByRef custom
As System.Array) Implements Extensibility.IDTExtensibility2.OnConnection
Try
oApp = CType(application, Outlook.Application)
oApp = application ' Get the Application object for Outlook.
oApp.ActiveExplorer.CommandBars("Standard").Visible = True 'It
will failed right here!
Catch ex As System.Exception
MsgBox("Failed to connect to outlook." & vbCrLf &
Err.Description, MsgBoxStyle.Critical, gstrMSGTitle)
End Try
End Sub
 
By XP do you mean Windows XP or the Outlook from Office XP? That Outlook is
actually Outlook 2002.

There may be cases where even if there is an Explorer (the user started
Outlook with a UI), there is no ActiveExplorer yet. You can test for an
ActiveExplorer in OnConnection or use Explorers.Count > 0. If that's the
case then you can use Explorers.Item(1) in place of ActiveExplorer. You can
also try moving your code to add a button or command bar into a different
place.

In all cases and all versions of Outlook you could trap the NewExplorer
event and then for that Explorer trap the Explorer.Activate event. Set a
Boolean or some flag to tell you not to add the button after the first
Activate event, but on that first Activate add your button or command bar.
That will always work.
 
Explorers.count is 1, and also I tried to replace activeExplorer with
Explorers.Item(1), I got same Error:
Unhandled "System ExecutionEngine Exception"...

The Env. is Windows XP and Outlook 2003 Sp1
 
I have feagured out the problem. I would like to share how I resolved it.
I removed the referance to Microsoft.Office.Core,
Microsoft.Office.Interop.Outlook then add them again. This solve the
problem.

Thanks.
 
Back
Top