Results 1 to 4 of 4

Thread: Seeking to add custom items to context menu

  1. #1

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    Seeking to add custom items to context menu

    I am using VS2015 and trying to create an outlook addin to add custom context menu items (when a user right-clicks on a mail item for instance). I have read this article:

    https://msdn.microsoft.com/en-us/lib...or=-2147217396

    However, I cannot get the GetCustomUI method to fire. Here is my code:

    Code:
    Public Class ThisAddIn
        Implements Microsoft.Office.Core.IRibbonExtensibility
    
        Private WithEvents myApp As Outlook.Application
    
        Private Sub ThisAddIn_Startup()
            Try
                myApp = Me.Application
            Catch ex As System.Exception
                Diagnostics.Debug.Print(ex.Message)
            End Try
    
        End Sub
    
        Private Sub ThisAddIn_Shutdown()
    
        End Sub
    
        Public Function GetCustomUI(RibbonID As String) As String Implements IRibbonExtensibility.GetCustomUI
            Diagnostics.Debug.Print(RibbonID)
            Return ""
        End Function
    
    End Class
    Can anyone help me find what I might be missing?
    Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment.

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Seeking to add custom items to context menu

    what I might be missing?
    Public Function GetCustomUI(RibbonID As String) As String Implements IRibbonExtensibility.GetCustomUI
    as far as i can see, this function is not being called, ribbonid has no value, there is no code to actually add items to the ribbon

    follow the links on link you posted for some examples
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    Re: Seeking to add custom items to context menu

    Quote Originally Posted by westconn1 View Post
    as far as i can see, this function is not being called, ribbonid has no value, there is no code to actually add items to the ribbon

    follow the links on link you posted for some examples
    Yes, I realise there is no code to add ribbon items but I need the routine to actually be invoked before I add them and it currently isn't. The article suggests that merely by implementing the IRobbonExtensibility interface it will be invoked.
    Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment.

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Seeking to add custom items to context menu

    normally such a function is called in the appropriate workbook open event and the additional controls removed from the ribbon on workbook beforeclose event
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width