| 1 |
joko |
1.1 |
VERSION 5.00 |
| 2 |
|
|
Begin {AC0714F6-3D04-11D1-AE7D-00A0C90F26F4} Connect |
| 3 |
|
|
ClientHeight = 7215 |
| 4 |
|
|
ClientLeft = 1740 |
| 5 |
|
|
ClientTop = 1545 |
| 6 |
|
|
ClientWidth = 6585 |
| 7 |
|
|
_ExtentX = 11615 |
| 8 |
|
|
_ExtentY = 12726 |
| 9 |
|
|
_Version = 393216 |
| 10 |
|
|
Description = "Sample Outlook Add-In" |
| 11 |
|
|
DisplayName = "MyAddIn" |
| 12 |
|
|
AppName = "Microsoft Outlook" |
| 13 |
|
|
AppVer = "Microsoft Outlook 9.0" |
| 14 |
|
|
LoadName = "Startup" |
| 15 |
|
|
LoadBehavior = 3 |
| 16 |
|
|
RegLocation = "HKEY_CURRENT_USER\Software\Microsoft\Office\Outlook" |
| 17 |
|
|
End |
| 18 |
|
|
Attribute VB_Name = "Connect" |
| 19 |
|
|
Attribute VB_GlobalNameSpace = False |
| 20 |
|
|
Attribute VB_Creatable = True |
| 21 |
|
|
Attribute VB_PredeclaredId = False |
| 22 |
|
|
Attribute VB_Exposed = True |
| 23 |
|
|
Option Explicit |
| 24 |
|
|
|
| 25 |
|
|
Dim oHostApp As Object |
| 26 |
|
|
Dim cmdBarControl As Office.CommandBarControl |
| 27 |
|
|
Dim WithEvents MyButton As Office.CommandBarButton |
| 28 |
|
|
Attribute MyButton.VB_VarHelpID = -1 |
| 29 |
|
|
|
| 30 |
|
|
Const cfgButtonTag As String = "ldapSyncButton" |
| 31 |
|
|
Const cfgButtonLabel As String = "Synchronize" |
| 32 |
|
|
|
| 33 |
|
|
Private Sub AddinInstance_OnConnection(ByVal Application As Object, _ |
| 34 |
|
|
ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, _ |
| 35 |
|
|
ByVal AddInInst As Object, custom() As Variant) |
| 36 |
|
|
|
| 37 |
|
|
Dim oCommandBars As Office.CommandBars |
| 38 |
|
|
Dim oStandardBar As Office.CommandBar |
| 39 |
|
|
|
| 40 |
|
|
On Error Resume Next |
| 41 |
|
|
|
| 42 |
|
|
Set oHostApp = Application |
| 43 |
|
|
|
| 44 |
|
|
MsgBox "My Addin started in " & Application.Name |
| 45 |
|
|
|
| 46 |
|
|
' Set up a custom button on the "Standard" commandbar... |
| 47 |
|
|
Set oCommandBars = oHostApp.CommandBars |
| 48 |
|
|
If oCommandBars Is Nothing Then |
| 49 |
|
|
' Outlook has the CommandBars collection on the Explorer object |
| 50 |
|
|
Set oCommandBars = oHostApp.ActiveExplorer.CommandBars |
| 51 |
|
|
End If |
| 52 |
|
|
|
| 53 |
|
|
Set oStandardBar = oCommandBars.Item("Standard") |
| 54 |
|
|
|
| 55 |
|
|
'Set MyButton = oHostApp.CommandBars("Standard").Controls.Add(1) |
| 56 |
|
|
|
| 57 |
|
|
' delete button in toolbar |
| 58 |
|
|
Set cmdBarControl = oStandardBar.FindControl(, , cfgButtonTag) |
| 59 |
|
|
cmdBarControl.Delete |
| 60 |
|
|
|
| 61 |
|
|
' add button to toolbar |
| 62 |
|
|
Set MyButton = oStandardBar.Controls.Item(cfgButtonLabel) |
| 63 |
|
|
|
| 64 |
|
|
If MyButton Is Nothing Then |
| 65 |
|
|
|
| 66 |
|
|
Set MyButton = oStandardBar.Controls.Add(1) |
| 67 |
|
|
With MyButton |
| 68 |
|
|
|
| 69 |
|
|
.Caption = cfgButtonLabel |
| 70 |
|
|
|
| 71 |
|
|
.Style = msoButtonCaption |
| 72 |
|
|
|
| 73 |
|
|
' The following items are optional, but recommended. |
| 74 |
|
|
' The Tag property lets you quickly find the control |
| 75 |
|
|
' and helps MSO keep track of it when there is more than |
| 76 |
|
|
' one application window visible. The property is required |
| 77 |
|
|
' by some Office applications and should be provided. |
| 78 |
|
|
|
| 79 |
|
|
.Tag = cfgButtonTag |
| 80 |
|
|
|
| 81 |
|
|
' The OnAction property is optional but recommended. |
| 82 |
|
|
' It should be set to the ProgID of the add-in, such that if |
| 83 |
|
|
' the add-in is not loaded when a user presses the button, |
| 84 |
|
|
' MSO loads the add-in automatically and then raises |
| 85 |
|
|
' the Click event for the add-in to handle. |
| 86 |
|
|
|
| 87 |
|
|
.OnAction = "!<" & AddInInst.ProgId & ">" |
| 88 |
|
|
|
| 89 |
|
|
.Visible = True |
| 90 |
|
|
|
| 91 |
|
|
End With |
| 92 |
|
|
End If |
| 93 |
|
|
|
| 94 |
|
|
End Sub |
| 95 |
|
|
|
| 96 |
|
|
Private Sub AddinInstance_OnDisconnection(ByVal RemoveMode As _ |
| 97 |
|
|
AddInDesignerObjects.ext_DisconnectMode, custom() As Variant) |
| 98 |
|
|
On Error Resume Next |
| 99 |
|
|
MsgBox "My Addin was disconnected by " & _ |
| 100 |
|
|
IIf(RemoveMode = ext_dm_HostShutdown, _ |
| 101 |
|
|
"Excel shutdown.", "end user.") |
| 102 |
|
|
|
| 103 |
|
|
MyButton.Delete |
| 104 |
|
|
|
| 105 |
|
|
Set MyButton = Nothing |
| 106 |
|
|
Set oHostApp = Nothing |
| 107 |
|
|
End Sub |
| 108 |
|
|
|
| 109 |
|
|
Private Sub MyButton_Click(ByVal Ctrl As Office.CommandBarButton, _ |
| 110 |
|
|
CancelDefault As Boolean) |
| 111 |
|
|
MsgBox "Our CommandBar button was pressed!" |
| 112 |
|
|
End Sub |
| 113 |
|
|
|
| 114 |
|
|
|