Hej, jag håller på att försöka få till en knapp/länk genom att använda VB.Net's com add-in. Problemet jag har är att försöka få dit denna endast på appointment-fönstret i outlook 2003.com add-in för outlook
Är det någon som har erfarenheter av detta som kanske har löst de problem som dyker upp:
<code>
Imports Microsoft.Office.Core
Imports Extensibility
Imports System.Runtime.InteropServices
' för debugging + ref i projektet
Imports System.Windows.Forms
#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 RoomMateAddInSetup project
' by right clicking the project in the Solution Explorer, then choosing install.
#End Region
<GuidAttribute("FADC37EA-776E-4083-B659-0B4FBAF89957"), ProgIdAttribute("RoomMateAddIn.Connect")> _
Public Class Connect
Implements Extensibility.IDTExtensibility2
Dim applicationObject As Object
Dim addInInstance As Object
Dim WithEvents RoomMateButton As CommandBarButton
Public Sub OnBeginShutdown(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnBeginShutdown
' raderar knappen och frigör den från Outlook
RoomMateButton.Delete()
RoomMateButton = 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
'
' adderar eller uppdaterar befintlig knapp
'
Dim oCommandBars As CommandBars
Dim oStandardBar As CommandBar
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
End If
'oStandardBar = oCommandBars.Item("Standard")
oStandardBar = oCommandBars.Item("RoomMate")
If oStandardBar Is Nothing Then
' Access names its main toolbar Database.
oStandardBar = oCommandBars.Item("Standard")
End If
' radera tidigare ev förekomster av objektet i toolbaren
Dim ptr As Integer
For ptr = 0 To oStandardBar.Controls.Count
If oStandardBar.Controls.Item(ptr).Tag = "RoomMateButton" Then
oStandardBar.Controls.Item(ptr).Delete()
End If
Next
' In case the button was not deleted, use the exiting one.
RoomMateButton = oStandardBar.Controls.Item("RoomMateButton")
'RoomMateButton = oStandardBar.FindControl(oStandardBar.Controls, Nothing, "RoomMateButton")
If RoomMateButton Is Nothing Then
' kontrollerar även om den inte finns igen
RoomMateButton = oStandardBar.Controls.Add(MsoBarType.msoBarTypeMenuBar, 1, , 1, False)
With RoomMateButton
.Caption = "RoomMate"
.Style = MsoButtonStyle.msoButtonCaption
' 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 = "RoomMateButton"
.ShortcutText = "Starting RoomMate"
' 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>"
.Visible = True
End With
Else
' finns redan
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
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
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 RoomMateButton_Click(ByVal Ctrl As Microsoft.Office.Core.CommandBarButton, ByRef
CancelDefault As Boolean) Handles RoomMateButton.Click
'MsgBox("RoomMate will start here!")
Shell("C:\program files\RoomMate\RoomMate.exe", AppWinStyle.NormalFocus, False)
End Sub
End Class
</code>