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