Hello!
I'm making VSTO add-in (VS2008) for helpdesk. I'm trying to customize Ribbon
on load "read email" inspector.
I have ready code, but I'm trying to do something like that:
When email is comming with subject "Opened entry" i want to display
RibbonGroup "New Call" with button "New"
When email will have subject "Call Update" i want to display only
RibbonGroup "Update Call" with button "Update"
I thought, that I can do this in OnLoad metod in Ribbon. But I'm getting
"Object is not set to an instance of an object". So it looks, like inspector
is not exist at this moment. But inspector is starting my ribbon. Maybe
someone have solution for this?
Piece of code from OnLoad:
Dim ol As New Microsoft.Office.Interop.Outlook.Application()
Dim NewMail As poczta.MailItem
NewMail = ol.ActiveInspector.CurrentItem
If NewMail.Subject.Contains("Opened entry") Then
grpUpdateRibbGroup.visible = false
End if
Norm Estabrook - 18 Mar 2008 18:36 GMT
Hi legrooch,
I just implemented this in my Outlook 2007 Add-in. Here is the entire
ThisAddIn class code. Please let me know if this works for you:
Public Class ThisAddIn
Private WithEvents inspectors As Outlook.Inspectors
Private Sub ThisAddIn_Startup(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Startup
inspectors = Me.Application.Inspectors
Dim inspector As Outlook.Inspector
For Each inspector In inspectors
Inspectors_NewInspector(inspector)
Next inspector
End Sub
Sub Inspectors_NewInspector(ByVal Inspector As Outlook.Inspector) _
Handles inspectors.NewInspector
If TypeOf Inspector.CurrentItem Is Outlook.MailItem Then
Dim myItem As Outlook.MailItem = CType(Inspector.CurrentItem,
Outlook.MailItem)
If myItem.Subject = "Opened entry" Then
Dim ribbonCollection As ThisRibbonCollection =
Globals.Ribbons _
(Globals.ThisAddIn.Application.ActiveInspector())
ribbonCollection.Ribbon1.grpUpdateRibbGroup.Visible = True
End If
End If
End Sub
Private Sub ThisAddIn_Shutdown(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Shutdown
End Sub
End Class
FYI - I pieced this solution together by referring to 2 topics in MSDN:
Walkthrough: Displaying Custom Task Panes in E-Mail Messages in Outlook at
http://msdn2.microsoft.com/en-us/library/bb296010.aspx. (I used this
walkthrough to figure out how to trap the NewInspector event.
Accessing the Ribbon at Run Time -
http://msdn2.microsoft.com/en-us/library/bb772088.aspx (I used this topic to
figure out how to access my Ribbon given the currently active inspector
window.
Hope this helps!
Norm E.
> Hello!
>
[quoted text clipped - 21 lines]
> grpUpdateRibbGroup.visible = false
> End if