none
Problem: - During uninstallation of Addins, Addins button (SaveDocument) is not removing from Microsoft Word and Microsoft Outlook RRS feed

  • Question

  • Type: critical issue

     

    Environment:

    OS : - Windows xp sp2

    IDE : - Visual Studio 2008

    Language : - VB .net

    Project type : - File --> New Project --> Others Project Types -->Extensibility --> Shared Add-in

     

    Problem Description: We have Addins component which runs properly. When we install this component It create a button {SaveDocument}on word and outlook.

    But when we uninstall the Addins component , It doesn’t  remove SaveDocument button.

     

    Requirement: -

    On uninstallation of Addins component. It should remove Addins button.

     

    Attempt : -

    I am sharing code snippet with you

     

    Public Sub OnBeginShutdown(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnBeginShutdown

    Try

    SaveDocument.Delete()

    SaveDocument = Nothing

            Catch ex As Exception

                MsgBox(ex.Message, MsgBoxStyle.Information)

     

    End Try

     

    When I captured this error on MsgBox It was showing

    Exception from HRESULT: 0x800A01A8

     

    After that I searched for this error code and I found article in outlook forum

    http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/d2998e9f-dc93-4e0a-baba-84c9e155cb0c/

     

    I tried almost everything but still I am not able to delete button from both application. This article is having explanation about Microsoft Word handling. I am sharing code snippet and an image for showing my activity for removing button from MSWord.

    I added AddIns.dotm file in the below mention path. After opening word document I found it was creating a file AddIns.dotm. For handling this file I wrote a code for URL

     

    http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/d2998e9f-dc93-4e0a-baba-84c9e155cb0c/

    That code was in C# I think I converted into VB .net

    I would like to share the code with you.

     

     

    Public Sub OnConnection(ByVal application As Object, ByVal connectMode As Extensibility.ext_ConnectMode, ByVal addInInst As Object, ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnConnection

            applicationObject = application

            addInInstance = addInInst

     

            'MsgBox("On Connection In MyAddin")

            applicationObject = application

            addInInstance = addInInst

     

     

            ' If you aren't in startup, manually call OnStartupComplete.

    If (connectMode <> Extensibility.ext_ConnectMode.ext_cm_Startup) Then _

               Call OnStartupComplete(custom)

            'MsgBox("Calling")

            wdApp = CType(application, Microsoft.Office.Interop.Word.Application)

      WordApp_DocumentChanged()

        End Sub

     

     

     

    Private Sub WordApp_DocumentChanged()

     

            If Not Intialized Then

     

     Dim currentTpl As Microsoft.Office.Interop.Word.Template = wdApp.CustomizationContext

     

    For Each tpl As Microsoft.Office.Interop.Word.Template In wdApp.Templates

                    If tpl.Name = "AddIns.dotm" Then

                        wdApp.CustomizationContext = tpl

                        Intialized = True

                        wdApp.CustomizationContext = currentTpl

                        Exit For

                    End If

    Next

         End If

    End Sub

     

    But when we run this code in Debug mode then in for each loop it only fetch Normal.dotm file.

    Please tell me If this way we can delete the button during uninstallation then where I am making mistake or suggest  the best way to remove button for both application (MSWord , MS Outlook)

    Please provide some fix code to remove button after uninstallation of Addins components or suggest something which will help to remove button from Addins.

     

    It is very critical issue. Please help me in this case.

    I will be thankful.

     



    • Edited by S.P Singh Friday, November 2, 2012 9:49 AM
    Friday, November 2, 2012 9:32 AM

Answers

  • For Outlook at least any customization of the CommandBars interface will store the customizations in a file named "outcmd.dat". The customizations will persist even if your addin is uninstalled.
     
    What you need to do is twofold. First, when any CommandBars interface is created it must be created using the Temporary argument set to true. Second, when the UI is no longer needed (for example when an Explorer or Inspector is closed) the UI should be explicitly deleted.
     
    That will prevent persistence of your UI.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "S.P Singh" <=?utf-8?B?Uy5QIFNpbmdo?=> wrote in message news:0ad1d69b-71c1-4b23-b37f-d14560334556...

    I will look into this but can you suggest some thing for which I will have to make less changes in the existing product.

    For excel product is working fine. It is removing the button while It is not working for word and outlook. Can we know the exact reason for error code Exception from HRESULT: 0x800A01A8 and find out the best way to resolve the issue.

    Thanks


    Ken Slovak MVP - Outlook
    Monday, November 5, 2012 3:31 PM
  • Since you're using Office 2007, the best thing would be to incorporate a Ribbon XML part in your add-in that defines the buttons. Since the add-in will load and unload the Ribbon extensions dynamically, nothing will be saved in the Office applications that would need to be uninstalled. Your starting point for this would be the article http://msdn.microsoft.com/en-us/library/aa338202(office.12).aspx.

    Your next stop after that would be the Outlook for Developers forum, where they can help you determine how to properly manage the Ribbon in the various Outlook views. (Although with 2007 I believe Outlook only uses the Ribbon in the message editor.)

    CommandBars are "deprecated" starting in Office 2007. The drawback with CommandBars is that the changes are saved in the application. With Word, it's even worse: the changs are saved in individual files (documents and templates). There's no way to remove these things when the add-in is uninstalled. Instead, the add-in must create them every time it loads and be sure to remove them when it unloads.


    Cindy Meister, VSTO/Word MVP, my blog

    Sunday, November 4, 2012 6:28 PM
    Moderator

All replies

  • Which version(s) of Office are targeted by your Add-in.

    Please show us the code that creates the buttons to which you refer.


    Cindy Meister, VSTO/Word MVP, my blog

    Friday, November 2, 2012 3:02 PM
    Moderator
  • It is Office 2007

    And code for creating the button

    Public Sub OnStartupComplete(ByRef custom As System.Array) Implements Extensibility.IDTExtensibility2.OnStartupComplete

            Dim oCommandBars As CommandBars
            Dim oStandardBar As CommandBar

            On Error Resume Next
            ' Set up a custom button on the "Standard" command bar.
            oCommandBars = applicationObject.CommandBars
            If oCommandBars Is Nothing Then
                ' Outlook has the CommandBars collection on the Explorer object.
                oCommandBars = applicationObject.ActiveExplorer.CommandBars
            End If

            oStandardBar = oCommandBars.Item("Standard")
           

            ' In case the button was not deleted, use the exiting one.
            MyButton = oStandardBar.Controls.Item("SaveDocument")
            If MyButton Is Nothing Then

                MyButton = oStandardBar.Controls.Add(1)
                With MyButton
                    .Caption = "SaveDocument"
                    .Style = MsoButtonStyle.msoButtonCaption
                    .Tag = "SaveDocument"
                    .OnAction = "!<MyCOMAddin.Connect>"

                    .Visible = True
                End With
            End If

            ' Display a simple message to show which application you started in.
            'MsgBox("Started in " & applicationObject.Name & ".")


            oStandardBar = Nothing
            oCommandBars = Nothing


        End Sub
    Saturday, November 3, 2012 6:05 PM
  • Since you're using Office 2007, the best thing would be to incorporate a Ribbon XML part in your add-in that defines the buttons. Since the add-in will load and unload the Ribbon extensions dynamically, nothing will be saved in the Office applications that would need to be uninstalled. Your starting point for this would be the article http://msdn.microsoft.com/en-us/library/aa338202(office.12).aspx.

    Your next stop after that would be the Outlook for Developers forum, where they can help you determine how to properly manage the Ribbon in the various Outlook views. (Although with 2007 I believe Outlook only uses the Ribbon in the message editor.)

    CommandBars are "deprecated" starting in Office 2007. The drawback with CommandBars is that the changes are saved in the application. With Word, it's even worse: the changs are saved in individual files (documents and templates). There's no way to remove these things when the add-in is uninstalled. Instead, the add-in must create them every time it loads and be sure to remove them when it unloads.


    Cindy Meister, VSTO/Word MVP, my blog

    Sunday, November 4, 2012 6:28 PM
    Moderator
  • I will look into this but can you suggest some thing for which I will have to make less changes in the existing product.

    For excel product is working fine. It is removing the button while It is not working for word and outlook. Can we know the exact reason for error code Exception from HRESULT: 0x800A01A8 and find out the best way to resolve the issue.

    Thanks

    Monday, November 5, 2012 5:02 AM
  • For Outlook at least any customization of the CommandBars interface will store the customizations in a file named "outcmd.dat". The customizations will persist even if your addin is uninstalled.
     
    What you need to do is twofold. First, when any CommandBars interface is created it must be created using the Temporary argument set to true. Second, when the UI is no longer needed (for example when an Explorer or Inspector is closed) the UI should be explicitly deleted.
     
    That will prevent persistence of your UI.

    --
    Ken Slovak
    [MVP-Outlook]
    http://www.slovaktech.com
    Author: Professional Programming Outlook 2007
    "S.P Singh" <=?utf-8?B?Uy5QIFNpbmdo?=> wrote in message news:0ad1d69b-71c1-4b23-b37f-d14560334556...

    I will look into this but can you suggest some thing for which I will have to make less changes in the existing product.

    For excel product is working fine. It is removing the button while It is not working for word and outlook. Can we know the exact reason for error code Exception from HRESULT: 0x800A01A8 and find out the best way to resolve the issue.

    Thanks


    Ken Slovak MVP - Outlook
    Monday, November 5, 2012 3:31 PM