Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / VS Tools for Office / March 2008

Tip: Looking for answers? Try searching our database.

Problem with customizong ribbon in Outlook 2007 OnLoad

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
legrooch - 18 Mar 2008 16:54 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.