none
no icon on a ribbon, Outlook Addin with VB.NET RRS feed

  • Question

  • Hi all

    i've some problems with an outlook addin i wrote with visual basic 2010 on Visual Studio 2010 professional and Outlook2010.

    I think it is quiet simple to solve but i'm working for hours on this without any solution.

    the addin creates a new ribbon and on that a new button.

    by clicking on this button a new message will be shown and automatic filled with an *.oft file.

    This all works just fine but what not works is the image/icon which is added to the button..

    My code:

     

    Imports Microsoft.Office.Tools.Ribbon
    
    Public Class Absenzenkarte
    
        Private Sub Button_Click(ByVal sender As System.Object, ByVal e As Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs) Handles button.Click
            Dim outlook As New Outlook.Application
            Dim msg = New Outlook.MailItem
            msg = outlook.CreateItemFromTemplate("P:\03_Human Resources\06_Ferien und Absenzen\Absence_Card_PF.oft")
            msg.Display()
        End Sub
    
        Private Sub Absenzenkarte_Load(ByVal sender As System.Object, ByVal e As Microsoft.Office.Tools.Ribbon.RibbonUIEventArgs) Handles MyBase.Load
            button.Image = My.Resources.absence_card
            button.ShowImage = True
        End Sub
    End Class
    
    '-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
        Protected Overrides Function CreateRibbonExtensibilityObject() As Microsoft.Office.Core.IRibbonExtensibility
            Return New Ribbon()
        End Function
        Private Sub ThisAddIn_Startup() Handles Me.Startup
            Dim absenzenkarte As New Absenzenkarte
            absenzenkarte.button.Image = My.Resources.absence_card
            absenzenkarte.button.ShowImage = True
            absenzenkarte.StartFromScratch = False
            absenzenkarte.Tab1.ControlId.ControlIdType = Microsoft.Office.Tools.Ribbon.RibbonControlIdType.Custom
        End Sub
    
    '-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
        Private ribbon As Office.IRibbonUI
    
        Public Sub New()
        End Sub
    
        Public Function GetCustomUI(ByVal ribbonID As String) As String Implements Office.IRibbonExtensibility.GetCustomUI
            Return GetResourceText("Absenzenkarte.Ribbon.xml")
        End Function
    
    #Region "Menübandrückrufe"
        'Erstellen Sie hier Rückrufmethoden. Weitere Informationen über das Hinzufügen von Rückrufmethoden erhalten Sie, indem Sie das Menüband-XML-Element im Projektmappen-Explorer markieren und dann F1 drücken.
        Public Sub Ribbon_Load(ByVal ribbonUI As Office.IRibbonUI)
            Me.ribbon = ribbonUI
            Dim Absenzenkarte As New Absenzenkarte
            Absenzenkarte.button.Image = My.Resources.absence_card
            Absenzenkarte.button.ShowImage = True
        End Sub
    
        Public Sub onAbsenceCardButton(ByVal control As Office.IRibbonControl)
            Dim objApp As New Outlook.Application
            Dim mail As Outlook.MailItem = CType(objApp.CreateItem( _
              Outlook.OlItemType.olMailItem), Outlook.MailItem)
            mail = objApp.CreateItemFromTemplate("P:\03_Human Resources\06_Ferien und Absenzen\Absence_Card_PF.oft")
            mail.Display()
        End Sub
    


    Thanks for help..

    Freeaak

    Friday, January 13, 2012 12:22 PM

All replies

  • Are you using the ribbon designer? If so just add the image to the Image property for the button in the property page for the button in the designer. No code needed.
     
    If you're using XML to create the button you can supply the image in a getImage callback you set up in the ribbon XML, or you can supply the image directly in the XML.

    --
    Ken Slovak
    MVP - Outlook
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
     
     
    "Freeaak" <=?utf-8?B?RnJlZWFhaw==?=> wrote in message news:342c8555-50c2-4a98-9d9d-f3cb56dc81d9...

    Hi all

    i've some problems with an outlook addin i wrote with visual basic 2010 on Visual Studio 2010 professional and Outlook2010.

    I think it is quiet simple to solve but i'm working for hours on this without any solution.

    the addin creates a new ribbon and on that a new button.

    by clicking on this button a new message will be shown and automatic filled with an *.oft file.

    This all works just fine but what not works is the image/icon which is added to the button..

    My code:

     

    Imports Microsoft.Office.Tools.Ribbon
    
    Public Class Absenzenkarte
    
        Private Sub Button_Click(ByVal sender As System.Object, ByVal e As Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs) Handles button.Click
            Dim outlook As New Outlook.Application
            Dim msg = New Outlook.MailItem
            msg = outlook.CreateItemFromTemplate("P:\03_Human Resources\06_Ferien und Absenzen\Absence_Card_PF.oft")
            msg.Display()
        End Sub
    
        Private Sub Absenzenkarte_Load(ByVal sender As System.Object, ByVal e As Microsoft.Office.Tools.Ribbon.RibbonUIEventArgs) Handles MyBase.Load
            button.Image = My.Resources.absence_card
            button.ShowImage = True
        End Sub
    End Class
    
    '-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
        Protected Overrides Function CreateRibbonExtensibilityObject() As Microsoft.Office.Core.IRibbonExtensibility
            Return New Ribbon()
        End Function
        Private Sub ThisAddIn_Startup() Handles Me.Startup
            Dim absenzenkarte As New Absenzenkarte
            absenzenkarte.button.Image = My.Resources.absence_card
            absenzenkarte.button.ShowImage = True
            absenzenkarte.StartFromScratch = False
            absenzenkarte.Tab1.ControlId.ControlIdType = Microsoft.Office.Tools.Ribbon.RibbonControlIdType.Custom
        End Sub
    
    '-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
        Private ribbon As Office.IRibbonUI
    
        Public Sub New()
        End Sub
    
        Public Function GetCustomUI(ByVal ribbonID As String) As String Implements Office.IRibbonExtensibility.GetCustomUI
            Return GetResourceText("Absenzenkarte.Ribbon.xml")
        End Function
    
    #Region "Menübandrückrufe"
        'Erstellen Sie hier Rückrufmethoden. Weitere Informationen über das Hinzufügen von Rückrufmethoden erhalten Sie, indem Sie das Menüband-XML-Element im Projektmappen-Explorer markieren und dann F1 drücken.
        Public Sub Ribbon_Load(ByVal ribbonUI As Office.IRibbonUI)
            Me.ribbon = ribbonUI
            Dim Absenzenkarte As New Absenzenkarte
            Absenzenkarte.button.Image = My.Resources.absence_card
            Absenzenkarte.button.ShowImage = True
        End Sub
    
        Public Sub onAbsenceCardButton(ByVal control As Office.IRibbonControl)
            Dim objApp As New Outlook.Application
            Dim mail As Outlook.MailItem = CType(objApp.CreateItem( _
              Outlook.OlItemType.olMailItem), Outlook.MailItem)
            mail = objApp.CreateItemFromTemplate("P:\03_Human Resources\06_Ferien und Absenzen\Absence_Card_PF.oft")
            mail.Display()
        End Sub
    


    Thanks for help..

    Freeaak


    Ken Slovak MVP - Outlook
    Friday, January 13, 2012 4:21 PM
  • Hello and thanks for your reply!

     

    I first used the designer to add the icon. In the designer view it was everything okay but as i started the program in debug mode or generated an *.exe file the icon was not visible. Is it possible to have too big icons, should the icon only 16x16 be?

    Then I tried to do it with code but nothing changed..

    Have you an idea how to create a xml getimage callback? I haven't.. :-)

     

    Freeaak

     

    Monday, January 16, 2012 8:51 AM
  • Hi,

     

    Following the code will helps you.

    Ribbon1.xml

     <button id="test" tag="test" size="large" label="click me" getImage ="ReturnImage"/>

     

    Ribbon1.vb

    'call back method to set the image

     Public Function ReturnImage(ByVal Control As Microsoft.Office.Core.IRibbonControl) As Image
            Return My.Resources.ImageName
        End Function

     


    venugopal
    • Edited by psvgopal Monday, January 16, 2012 10:17 AM
    • Proposed as answer by Jeremy J Wong Tuesday, January 17, 2012 3:44 AM
    Monday, January 16, 2012 10:16 AM