Outlook CommandBar IDs?

B

Bingo

Are these IDs fixed or they can be different on different
versions of Outlook, even on different Windows or even
different PCs? Thanks.
 
S

Sue Mosher [MVP-Outlook]

They're fixed, except for the few commands that have the same name but
operate slightly differently in different versions.
 
S

Sue Mosher [MVP-Outlook]

If you don't want to write your own code to recurse the Explorer.CommandBars
and Inspector.CommandBars collections, you can use either the CommandBars
Browser or Outlook Spy tools listed at
http://www.slipstick.com/dev/vb.htm#tools

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
B

Bingo

Sue,

I've my own code to do this. But I do not have all the
combinations of Outlook and Windows for me to check.
Thanks.
 
S

Sue Mosher [MVP-Outlook]

You don't need a tool specifically for VB.NET to browse CommandBar IDs. The
same IDs work in all versions.

The right URl for the tools is at http://www.outlookcode.com/d/vb.htm#tools
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
G

Guest

Hi Sue,

Sorry but I am new to this...but the tool mentions (in readme.txt) how to
use/activate it in VBE not in visual studio .net 2003 (the one I use).
Is there any way to do that from there?

In any case my real problem is different. Maybe as an outlook guru you can
help:

I am adding a commandbar to the explorerwindow. it works fine...

But when I am trying to add it to an inspector window it doesn't!

I did catch (a
 
G

Guest

Sorry for the previous post it was incomplete...

Hi Sue,

Sorry but I am new to this...but the tool mentions (in readme.txt) how to
use/activate it in VBE not in visual studio .net 2003 (the one I use).
Is there any way to do that from there?

In any case my real problem is different. Maybe as an outlook guru you can
help:

I am adding a commandbar to the explorerwindow. it works fine...

But when I am trying to add it to an inspector window it doesn't!

I did catch the newinspector event (debugging gave me evidence of this) but
it starts going strange at the line :
====================

' here it just pops-up the inspector window and that's it...
seems not to run further in my managed code!
oCommandBars = myInspector.CommandBars
====================

here is a full extract of my connect.vb module.

==================================================
Imports Microsoft.Office.Core
imports Extensibility
imports System.Runtime.InteropServices


#Region " Read me for Add-in installation and setup information. "
' When run, the Add-in wizard prepared the registry for the Add-in.
' At a later time, if the Add-in becomes unavailable for reasons such as:
' 1) You moved this project to a computer other than which is was
originally created on.
' 2) You chose 'Yes' when presented with a message asking if you wish to
remove the Add-in.
' 3) Registry corruption.
' you will need to re-register the Add-in by building the MyAddin5Setup
project
' by right clicking the project in the Solution Explorer, then choosing
install.
#End Region

<GuidAttribute("3681FC2F-A00F-44BD-8C41-1EDD5B558CAE"),
ProgIdAttribute("MyAddin5.Connect")> _
Public Class Connect

Implements Extensibility.IDTExtensibility2

Dim applicationObject As Object
Dim addInInstance As Object
Dim WithEvents MyButton As Microsoft.Office.Core.CommandBarButton
Dim WithEvents MySecondButton As CommandBarButton
Dim WithEvents myInspectors As Microsoft.Office.Interop.Outlook.Inspectors
Dim WithEvents myOwnInspector As
Microsoft.Office.Interop.Outlook.Inspector
Dim WithEvents myCdBars As CommandBars



Public Sub OnBeginShutdown(ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnBeginShutdown
On Error Resume Next
' Notify the user you are shutting down, and delete the button.
' MsgBox("Our custom Add-in is unloading.")
MyButton.Delete()
MyButton = Nothing

End Sub

Public Sub OnAddInsUpdate(ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnAddInsUpdate
'
End Sub

Public Sub OnStartupComplete(ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnStartupComplete

Dim oCommandBars As CommandBars
Dim oStandardBar As CommandBar
Dim oCommandBars2 As CommandBars
Dim oStandardBar2 As CommandBar

' Get this type's assembly
Dim assem As System.Reflection.Assembly

assem = Me.GetType().Assembly

' Load the resource using a namespace
' Will load resource named "ResourcesApp.Azul.jpg"
Dim myStream As System.IO.Stream

myStream = assem.GetManifestResourceStream(Me.GetType(), "Skype
Button.bmp")

' Load the bitmap from the stream
' this.BackgroundImage = new Bitmap(stream);
Dim myBitmap As System.Drawing.Bitmap

myBitmap = System.Drawing.Bitmap.FromStream(myStream)

' MsgBox("Bitmap loaded...")
On Error Resume Next
' Set up a custom button on the "Standard" command bar.
oCommandBars = applicationObject.CommandBars

If oCommandBars Is Nothing Then
' Outlook has the CommandBars collection on the Explorer object.
oCommandBars = applicationObject.ActiveExplorer.CommandBars
oCommandBars2 = applicationObject.ActiveInspector.CommandBars
Dim bar As CommandBar


For Each bar In oCommandBars
MsgBox(bar.Name)
Next
For Each bar In oCommandBars2
MsgBox(bar.Name)
Next

End If

' in case the bar was there
oStandardBar = oCommandBars.Item("aXialyze toolbar")
If oStandardBar Is Nothing Then

oStandardBar = oCommandBars.Add("aXialyze toolbar",
Microsoft.Office.Core.MsoBarPosition.msoBarTop)

End If

oStandardBar.Visible = True

' In case the button was not deleted, use the exiting one.
MyButton = oStandardBar.Controls.Item("Call Skype...")
If MyButton Is Nothing Then

MyButton = oStandardBar.Controls.Add(1)
With MyButton
.Caption = "Call Skype..."
.Style = MsoButtonStyle.msoButtonIconAndCaption


' The following items are optional, but recommended.
' The Tag property lets you quickly find the control
' and helps MSO keep track of it when more than
' one application window is visible. The property is required
' by some Office applications and should be provided.

.Tag = "Call Skype..."

' The OnAction property is optional but recommended.
' It should be set to the ProgID of the add-in, so that if
' the add-in is not loaded when a user clicks the button,
' MSO loads the add-in automatically and then raises
' the Click event for the add-in to handle.

.OnAction = "!<MyCOMAddin.Connect>"

' try to load an image...

System.Windows.Forms.Clipboard.SetDataObject(myBitmap, True)
.FaceId = 0
.PasteFace()

' yeap...
.Visible = True
End With
End If

' Display a simple message to show which application you started in.
'MsgBox("Started in " & applicationObject.Name & ".")


myInspectors = applicationObject.Inspectors



oStandardBar = Nothing
oCommandBars = Nothing


End Sub

Public Sub OnNewInspector(ByVal myInspector As
Microsoft.Office.Interop.Outlook.Inspector) Handles myInspectors.NewInspector

'just make sure I get it ... so that I can catch its actvation...

myOwnInspector = myInspector



Dim oCommandBars As CommandBarsClass
Dim oStandardBar As CommandBar

' Get this type's assembly
Dim assem As System.Reflection.Assembly

assem = Me.GetType().Assembly

' Load the resource using a namespace
' Will load resource named "ResourcesApp.Azul.jpg"
Dim myStream As System.IO.Stream

myStream = assem.GetManifestResourceStream(Me.GetType(), "Skype
Button.bmp")

' Load the bitmap from the stream
' this.BackgroundImage = new Bitmap(stream);
Dim myBitmap As System.Drawing.Bitmap

myBitmap = System.Drawing.Bitmap.FromStream(myStream)

' On Error Resume Next
' Set up a custom button on the "Standard" command bar.
Dim oItem As Object



Dim bar As CommandBar
Dim i As Integer
Dim j As Integer



Try
' here it just pops-up the inspector window and that's it...
seems not to run further in my managed code!
oCommandBars = myInspector.CommandBars

j = oCommandBars.Count

Catch e As System.ExecutionEngineException
MsgBox(e.ToString())
End Try


If oCommandBars Is Nothing Then
'shit happens
MsgBox("here it fails...")
Else
For i = 0 To j
bar = oCommandBars.Item(i)
MsgBox(bar.Name & bar.Visible)
Next i
End If

' in case the bar was there
oStandardBar = oCommandBars.Item("aXialyze toolbar")
If oStandardBar Is Nothing Then

oStandardBar = oCommandBars.Add("aXialyze toolbar",
Microsoft.Office.Core.MsoBarPosition.msoBarTop)

MsgBox("there was no cmdbar...")
End If

oStandardBar.Visible = True

For Each bar In oCommandBars
MsgBox(bar.Name & bar.Visible)
Next


' In case the button was not deleted, use the exiting one.
MySecondButton = oStandardBar.Controls.Item("Call Skype...")
If MySecondButton Is Nothing Then
MsgBox("button did not exist...")

MySecondButton = oStandardBar.Controls.Add(1)
With MySecondButton
.Caption = "Call Skype..."
.Style = MsoButtonStyle.msoButtonIconAndCaption

' The following items are optional, but recommended.
' The Tag property lets you quickly find the control
' and helps MSO keep track of it when more than
' one application window is visible. The property is required
' by some Office applications and should be provided.

.Tag = "Call Skype..."

' The OnAction property is optional but recommended.
' It should be set to the ProgID of the add-in, so that if
' the add-in is not loaded when a user clicks the button,
' MSO loads the add-in automatically and then raises
' the Click event for the add-in to handle.

.OnAction = "!<MyCOMAddin.Connect>"

' try to load an image...

System.Windows.Forms.Clipboard.SetDataObject(myBitmap, True)
.FaceId = 0
.PasteFace()

' yeap...
.Visible = True
End With
End If

' Display a simple message to show which application you started in.
'MsgBox("Started in " & applicationObject.Name & ".")


oStandardBar = Nothing
oCommandBars = Nothing




End Sub

Public Sub OnDisconnection(ByVal RemoveMode As
Extensibility.ext_DisconnectMode, ByRef custom As System.Array) Implements
Extensibility.IDTExtensibility2.OnDisconnection

On Error Resume Next
If RemoveMode <>
Extensibility.ext_DisconnectMode.ext_dm_HostShutdown Then _
Call OnBeginShutdown(custom)

applicationObject = Nothing


End Sub

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


MsgBox("On Connection In MyAddin")
applicationObject = application
addInInstance = addInInst


' If you aren't in startup, manually call OnStartupComplete.
If (connectMode <> Extensibility.ext_ConnectMode.ext_cm_Startup)
Then _
Call OnStartupComplete(custom)

End Sub


Private Sub MyButton_Click(ByVal Ctrl As
Microsoft.Office.Core.CommandBarButton, ByRef CancelDefault As Boolean)
Handles MyButton.Click, MySecondButton.Click
MsgBox("Our CommandBar button was pressed!")
'Call modSkype.CallSkype()

End Sub



End Class

==================================================

Thanks if you can help
Luc
 
S

Sue Mosher [MVP-Outlook]

No one has written such a thing for VB.NET that I know of. It's not
something that you'd use every day. I use Outlook Spy myself. And I'm sure
you can write your own code to iterate commandbar IDs if it comes to that.

I'd suggest that you post your issue with Inspector toolbars in VB.NET as a
new thread, since it's unrelated to your original question. You might pare
down the code sample to just the minimum needed to demonstrate the problem.
You'll also want to specify whether the problem occurs on all Inspector
windows or only those for certain types of items -- e.g. messages vs.
others.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
G

Guest

Thanks Sue,

I'll post it there... just in case...

In fact I did put the whole code so that it can be easily copied/pasted and
run but an expert who could investigate... as mentionned the problem occurs
in the first code snippet in my post (substring of the long one)

Thanks anyway.
Cheers
Luc
 
S

Sue Mosher [MVP-Outlook]

I was suggesting that removing the code that's not related to your
particular issue would make it more likely that an expert would take the
time to look at it.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
G

Guest

Got the point....

I'll do so next time. Thanks for the hint.

Cheers
Luc

PS: I hope that there is someone expert enough to help with that very
peculiar behaviour of an outlook add-in and that he/she will take the time to
look at it...
...although the fact you cannot help makes me anticipate it will be hard to
find (are there better experts than you in outlook/VB - .Net or not - ?)
 
S

Sue Mosher [MVP-Outlook]

A lot of people hang out here. But I have personally have found doing
Outlook add-ins with VB.NET quite frustrating. I'm not willing to put any
more time into the effort for the time being.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
G

Guest

I start to share the feeling... but on the other hand .NETY is quite a
fantastic dev platform so getting in to work with office could be a blast to
dev productivity of ... productivity applications.
Thanks a lot for your help
Luc
 

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