1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215
| Option Explicit
Private WithEvents objOLApp As outlook.Application
Dim WithEvents objBtnExpRappel As Office.CommandBarButton
Dim WithEvents objBtnInsRappel As Office.CommandBarButton
Implements IRibbonExtensibility
Private Sub AddinInstance_OnConnection(ByVal Application As Object, _
ByVal ConnectMode As AddInDesignerObjects.ext_ConnectMode, _
ByVal AddInInst As Object, custom() As Variant)
'Set my object to the host application.
On Error GoTo AddinInstance_OnConnection_Error
Set objOLApp = Application
If Val(objOLApp.Version) < 14 Then
Dim objBar As Office.CommandBar
On Error Resume Next
Set objBar = objOLApp.ActiveExplorer.CommandBars.item("DZ")
If objBar Is Nothing Then
Set objBar = objOLApp.ActiveExplorer.CommandBars.Add("DZ", msoBarTop, , True)
End If
On Error GoTo AddinInstance_OnConnection_Error
Set objBtnExpRappel = objBar.Controls.Add(, , , 1, True)
With objBtnExpRappel
.FaceId = 2604
.Caption = "[Bouton1]"
.Style = msoButtonIconAndCaption
' The OnAction property is optional but recommended.
' It should be set to the ProgID of the add-in, such that if
' the add-in is not loaded when a user presses the button,
' Outlook loads the add-in automatically and then raises
' the Click event for the add-in to handle.
.OnAction = "!<" & AddInInst.ProgId & ">"
End With
objBar.Visible = True
'On Error Resume Next
Dim objBarInsp As Office.CommandBar
Dim oItm 'As outlook.MailItem
Dim OItms 'As Outlook.Items
'Set oItm = objOLApp.CreateItem(olMailItem)
Set OItms = objOLApp.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).Items
If OItms.Count > 0 Then
Dim j
j = 0
Do
j = 1 + 1
Set oItm = OItms(j)
j = j + 1
Loop While oItm.Class <> olMail
'oItm.Display
On Error Resume Next
Set objBarInsp = oItm.GetInspector.CommandBars.item("read_DZ")
objBarInsp.Delete
If objBarInsp Is Nothing Then
Set objBarInsp = oItm.GetInspector.CommandBars.Add("read_DZ", msoBarTop, , True)
End If
On Error GoTo 0 'AddinInstance_OnConnection_Error
DoEvents
Set objBtnInsRappel = objBarInsp.Controls.Add(, , , 1, True)
' DoEvents
With objBtnInsRappel
.FaceId = 2604
.Caption = "[ Bouton1 ]"
.Style = msoButtonIconAndCaption
' The OnAction property is optional but recommended.
' It should be set to the ProgID of the add-in, such that if
' the add-in is not loaded when a user presses the button,
' Outlook loads the add-in automatically and then raises
' the Click event for the add-in to handle.
.OnAction = "!<" & AddInInst.ProgId & ">"
End With
objBarInsp.Visible = True
oItm.Close olDiscard
End If
Set oItm = Nothing
End If
On Error GoTo 0
Exit Sub
AddinInstance_OnConnection_Error:
MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure AddinInstance_OnConnection of Concepteur Connect"
'Resume
End Sub
Private Sub objBtnExpRappel_Click(ByVal Ctrl As Office.CommandBarButton, _
CancelDefault As Boolean)
Go_BOUTON "BOUTON1"
End Sub
Private Sub objBtnInsRappel_Click(ByVal Ctrl As Office.CommandBarButton, _
CancelDefault As Boolean)
Go_BOUTON_Current "BOUTON1"
End Sub
Private Sub objOLApp_ItemSend(ByVal item As Object, Cancel As Boolean)
Cancel = Fire_ItemSend(item, Cancel)
End Sub
Private Sub AddinInstance_OnDisconnection(ByVal RemoveMode As _
AddInDesignerObjects.ext_DisconnectMode, custom() As Variant)
'Clean up objects that are created during the OnConnection event.
Set objOLApp = Nothing
End Sub
Public Function IRibbonExtensibility_GetCustomUI(ByVal RibbonID As String) As String
'RibbonID indicates type of Inspector that is about to be displayed,
' valid RibbonID values are as follows:
'Microsoft.Outlook.Mail.Read
'Microsoft.Outlook.Mail.Compose
'Microsoft.Outlook.MeetingRequest.Read
'Microsoft.Outlook.MeetingRequest.Send
'Microsoft.Outlook.Appointment
'Microsoft.Outlook.Contact
'Microsoft.Outlook.Journal
'Microsoft.Outlook.Task
'Microsoft.Outlook.DistributionList
'Microsoft.Outlook.Report
'Microsoft.Outlook.Resend
'Microsoft.Outlook.Response.Read
'Microsoft.Outlook.Response.Compose
'Microsoft.Outlook.Response.CounterPropose
'Microsoft.Outlook.RSS
'Microsoft.Outlook.Post.Read
'Microsoft.Outlook.Post.Compose
'Microsoft.Outlook.Sharing.Read
'Microsoft.Outlook.Sharing.Compose
Select Case RibbonID
Case "Microsoft.Outlook.Explorer"
IRibbonExtensibility_GetCustomUI = GetRibbonXML_EXP()
Case "Microsoft.Outlook.Mail.Compose"
Case "Microsoft.Outlook.Mail.Read"
IRibbonExtensibility_GetCustomUI = GetRibbonXML()
End Select
End Function
Public Function GetRibbonXML() As String
Dim sRibbonXML As String
sRibbonXML = "<customUI xmlns=""http://schemas.microsoft.com/office/2009/07/customui"" >" & _
"<ribbon>" & _
"<tabs>" & _
"<tab idMso=""TabReadMessage"">" & _
"<group id=""DZ.AB503B5"" label=""DZ"" imageMso=""RmsSendBizcardDesign"" insertBeforeQ=""GroupShow"" autoScale=""true"">" & _
"<button id=""readMail_BOUTON1"" label=""BOUTON1"" imageMso=""SendAgain"" size=""large"" onAction=""Clik_ribbon"" />" & _
"<button id=""readMail_BOUTON2"" label=""BOUTON2"" imageMso=""SendAgain"" size=""large"" onAction=""Clik_ribbon"" />" & _
"</group >" & _
"</tab>" & _
"</tabs>" & _
"</ribbon>" & _
"</customUI>"
GetRibbonXML = sRibbonXML
End Function
Public Function GetRibbonXML_EXP() As String
Dim sRibbonXML As String
sRibbonXML = "<customUI xmlns=""http://schemas.microsoft.com/office/2009/07/customui"" >" & _
"<ribbon>" & _
"<tabs>" & _
"<tab idMso=""TabMail"">" & _
"<group id=""DZ.AB503B5"" label=""DZ"" imageMso=""RmsSendBizcardDesign"" insertBeforeQ=""GroupQuickSteps"" autoScale=""true"">" & _
"<button id=""EXPLMail_BOUTON1"" label=""BOUTON1"" imageMso=""SendAgain"" size=""large"" onAction=""Clik_ribbon"" />" & _
"<button id=""EXPLMail_BOUTON2"" label=""BOUTON2"" imageMso=""SendAgain"" size=""large"" onAction=""Clik_ribbon"" />" & _
"<button id=""EXPLMail_OPTIONS"" label=""OPTIONS"" imageMso=""ControlsGallery"" size=""normal"" onAction=""Clik_ribbon"" showLabel=""false""/>" & _
"</group >" & _
"</tab>" & _
"</tabs>" & _
"</ribbon>" & _
"</customUI>"
GetRibbonXML_EXP = sRibbonXML
End Function
Public Sub Clik_ribbon(ByVal control As IRibbonControl)
Select Case control.Id
Case "readMail_BOUTON1"
Go_BOUTON_Current "BOUTON1"
Case "EXPLMail_BOUTON1"
Go_BOUTON "BOUTON1"
Case "readMail_BOUTON2"
Go_BOUTON_Current "BOUTON2"
Case "EXPLMail_BOUTON2"
Go_BOUTON "BOUTON2"
Case "EXPLMail_OPTIONS"
MsgBox "aucunes" 'FrmINI.Show
Case Else
MsgBox "Pas implémenté", vbCritical, "MonAddinDeveloppez"
End Select
End Sub |
Partager