Posizione VSTO CommandBarButton
-
21-08-2019 - |
Domanda
Sto scrivendo un VSTO add-in per aggiungere un pulsante nella barra degli strumenti standard per tutti i nuovi MailItems in Outlook 2003.
Ho lo più finito, ma non riesco a vedere per capire come impostare la posizione del pulsante sulla barra delle applicazioni -. Idealmente mi piacerebbe per posizionarlo accanto al pulsante Invia
Ecco il codice che ho finora.
Private Sub colInsp_NewInspector(ByVal Inspector As Microsoft.Office.Interop.Outlook.Inspector) Handles colInsp.NewInspector
Dim msg As Outlook.MailItem
Dim commandBar As Office.CommandBar
Dim encryptButton As Office.CommandBarButton
Dim olkitem As Object
olkitem = Me.ActiveInspector().CurrentItem
If TypeOf Inspector.CurrentItem Is Outlook.MailItem Then
msg = CType(Inspector.CurrentItem, Outlook.MailItem)
commandBar = Inspector.CommandBars("Standard")
encryptButton = commandBar.FindControl(Tag:="EncryptMail")
If Not (encryptButton Is Nothing) Then
encryptButton.Delete()
End If
encryptButton = CType(commandBar.Controls.Add(1), Office.CommandBarButton)
encryptButton.Style = Office.MsoButtonStyle.msoButtonIconAndCaption
encryptButton.FaceId = 718
encryptButton.Caption = "Secure Email"
encryptButton.Tag = "EncryptMail"
If olkitem.Sensitivity = Outlook.OlSensitivity.olConfidential Then
encryptButton.State = Office.MsoButtonState.msoButtonDown
End If
AddHandler encryptButton.Click, AddressOf encryptButton_Click
msg = Nothing
End If
End Sub
Qualsiasi aiuto sarebbe enormemente apprezzato!
Grazie, Jim.
Soluzione
avrei dovuto usare la sintassi commandBar.AddControl(control, position)
invece
Altri suggerimenti
in Outlook 2007:
(Office.CommandBarButton)commandBars["Standard"].Controls.Add(Office.MsoControlType.msoControlButton, System.Reflection.Missing.Value, System.Reflection.Missing.Value,2,true);
dove 2
è il numero di posizioni.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow