Imports Microsoft.Office.Interop.Outlook Imports System.Data.SqlClient Imports System.Data.SqlServerCe Imports System.Text.RegularExpressions Imports Microsoft.Office.Core Public Class ThisAddIn Dim WithEvents MyApp As Outlook.Application = Nothing Dim MyNS As Outlook.NameSpace = Nothing Dim WithEvents MyButton As Office.CommandBarButton Private Sub ThisAddIn_Startup() Handles Me.Startup Dim StandardToolbar As Office.CommandBar = Application.ActiveExplorer.CommandBars("Standard") AddButton(ButtonCaption:="GARY1", ButtonTag:="GARY2", ButtonIcon:=3) MyApp = Application MyNS = MyApp.GetNamespace("MAPI") End Sub Private Sub AddButton(ByVal ButtonCaption As String, ByVal ButtonTag As String, ByVal ButtonIcon As String) Dim MyButton As Office.CommandBarButton Dim StandardToolbar As Office.CommandBar = Application.ActiveExplorer.CommandBars("Standard") Try ' If the button already exists, remove it MyButton = StandardToolbar.FindControl(Tag:=ButtonTag) If MyButton IsNot Nothing Then MyButton.Delete(True) End If Catch Ex As InvalidOperationException 'Exception MsgBox(Ex.Message) End Try 'create the control MyButton = CType(StandardToolbar.Controls.Add(Type:=1, Before:=8, Temporary:=True), Office.CommandBarButton) With MyButton '.Picture .Style = Microsoft.Office.Core.MsoButtonStyle.msoButtonIconAndCaption .Caption = ButtonCaption .Tag = ButtonTag .FaceId = ButtonIcon .OnAction = "!<ThisAddIn.Test>" End With AddHandler MyButton.Click, AddressOf GARY3 End Sub Public Function Test() As String MsgBox("Test") Test = "x" End Function Private Sub GARY3(ByVal ctrl As Office.CommandBarButton, ByRef Cancel As Boolean) MsgBox("GARY4") End Sub Private Sub ThisAddIn_Shutdown() Handles Me.Shutdown End Sub
Private Sub PressMyButton() Handles MyButton.Click Dim myEmailForm As New EmailForm myEmailForm.Show() End Sub
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)