none
When handle event add-in stop uninstall RRS feed

  • Question

  • Hi all.

    I'm having a serious problem, I created a new project of shared-addin, to create a addin to Excel 2002.

    every thing is fine except the fact that if I handle any event breaks the normal behavior

    I have this code

    public void OnConnection(object application, Extensibility.ext_ConnectMode connectMode, object addInInst, ref System.Array custom)
            {
                applicationObject = application;
                addInInstance = addInInst;

                ((Microsoft.Office.Interop.Excel.AppEvents_Event)applicationObject).NewWorkbook += new Microsoft.Office.Interop.Excel.AppEvents_NewWorkbookEventHandler(Connect_NewWorkbook);
            }

            void Connect_NewWorkbook(Microsoft.Office.Interop.Excel.Workbook Wb)
            {
            }

     

    When I try to add any add-in on excel for example solver works fine, but when I remove the add-in (solver) It does not remove, if I type Ctrl+F11 to go to the VB view the project still there SOLVER.XLA, and if add again the Add-in it create a new SOLVER.XLA.

    The strange thing is if I remove this line

    ((Microsoft.Office.Interop.Excel.AppEvents_Event)applicationObject).NewWorkbook += new Microsoft.Office.Interop.Excel.AppEvents_NewWorkbookEventHandler(Connect_NewWorkbook);

    Everything back to normal

     

    Any ideia ?



    Thursday, October 13, 2011 1:50 PM

Answers

  • Thank you very much, it helped me a lot, but after banging my head against the wall, I discovered EXCEL DNA, wanderfull, smoth and easy.

    thank you very much for your help.


    Tuesday, October 18, 2011 7:10 PM

All replies

  • Hi Fernando,

     

    Thanks for posting in the MSDN Forum.

     

    It’s based on my experience that you add an Excel add-in to your Excel workbook and don’t know how to remove it, is it right?

     

    I will recommend you use follow snippet to remove it:

    Sub test()
        Dim MyAddIn As Excel.AddIn
        
        For Each MyAddIn In Application.AddIns
            If MyAddIn.FullName = "[You add-in file's path]" Then
                MyAddIn.Installed = False
            End If
            Set MyAddIn = Nothing
        Next
    End Sub
    

     

    And you can disable it from add-in list also.

     

    Then please remove this add-in file from you disk.

     

    If I have misunderstood anything, please feel free to let me know.

     

    Have a good day,

     

    Tom

     

     

     


    Tom Xu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    Monday, October 17, 2011 2:19 AM
    Moderator
  • Thanks for the reply

    No, that's not what is happaning, when I install my add-in, the normals add-ins from excel stop working propertly, the example that I gave is solver, which is a regular add-in from excel, if I install my add-in,and write this line of code

    ((Microsoft.Office.Interop.Excel.AppEvents_Event)applicationObject).NewWorkbook += new Microsoft.Office.Interop.Excel.AppEvents_NewWorkbookEventHandler(Connect_NewWorkbook);

    It stops working. If I comment this line, everything back to normal, but it is not the NewWorkbook event, any event that I handle I get the same behavior.

    Monday, October 17, 2011 12:03 PM
  • one more information, I'm using office 2002 (XP), and this started to happen after I installed vs2005-kb908002-enu-x86 FIX.
    Monday, October 17, 2011 5:08 PM
  • Hello Fernando,

    You report that the problem started to happen after you installed VS2005-KB908002-enu-x86 FIX.  In the notes in the KB article is the information below:

    “After you install this update, whenever you create a shared add-in project in Visual Studio 2005, you must include the Shared Add-in Support Update for the Microsoft .NET Framework 2.0 (KB908002) option among the prerequisites in the solution Setup project. To do this, follow these steps: 1. In Solution Explorer, right-click the solution Setup project, and then click Properties.
    2. Click Prerequisites.
    3. Click to select the Shared Add-in Support Update for the Microsoft .NET Framework 2.0 (KB908002) check box.
    Note You must enable this prerequisite separately for both Debug and Release builds."
    (end of inserted comments)

    There are many forum links under :
    http://www.add-in-express.com/forum/read.php?FID=5&TID=13062
    You might browse that to see if any referred to the problem you are having. (I didn’t see one that immediately struck me as describing the same problem you’re experiencing.)

    Please look at the information about Otkloadr.dll in the following Solution Object from VKB:

    SOX060705700014             The out of the box experience for Microsoft Word and Microsoft Excel extensibility add-in project is broken in Microsoft Visual Studio 2005
    https://vkbexternal.partners.extranet.microsoft.com/VKBWebService/ViewContent.aspx?scid=SO;US;SOX060705700014

    Here is more information about either or both otkloadr and KB908002

    “After you install this update, you must include the Shared Add-in Support Update for the Microsoft .NET Framework 2.0 (KB908002) option among the prerequisites in the solution Setup project whenever you create a shared add-in project in Visual Studio 2005. To do this, follow these steps:

    1.       In Solution Explorer, right-click the solution Setup project, and then click Properties.

    2.       Click Prerequisites.

    3.       Click to select the Shared Add-in Support Update for the Microsoft .NET Framework 2.0 (KB908002) check box.

    Note You must enable this prerequisite separately for both Debug and Release builds.

    Note This update is installed on a per-user basis. Therefore, install the update for each user account that requires the update.

    Whenever you build your Setup project, Visual Studio 2005 will include the redistributable updates with your project in a folder that is named KB908002. This folder is located in the application Setup folder. The contents of the KB908002 folder are required for the solution Setup logic to work correctly. The Setup.exe file that Visual Studio 2005 builds with the Setup project will apply the updates to the destination computer when the solution is installed.

    Note The .NET Framework 2.0 and Microsoft Windows Installer 2.0 are required for the fixes to be installed correctly on the destination computer.

    Note This .msi file has no ALLUSERS specification. Therefore, when you install this .msi file, the file is installed in the user context per-user instead of per-machine.”
    (end of segment from the article)

    Since your add-in is a shared application Extensibility project you aren’t dealing with Visual Studio Tools for Office so the service Pack for that wouldn’t be applicable to your situation.

    I don’t have the combination of Operating System, Office XP, and Visual Studio 2005 but I have built a shared add-in using extensibility in Visual Studio 2010 using your code. It did not cause the problem you report.  Solver and Analysis Tool Pack were both loaded and functional.  The symptoms you’re experiencing point to the installation of the KB908002 fix. If you uninstall it do you still see the problem?

    Please let us know if the solution to your problem is in changing anything discussed above.

    Regards,
    Chris Jensen
    Senior Technical Support Lead

    Tuesday, October 18, 2011 5:51 PM
    Moderator
  • Thank you very much, it helped me a lot, but after banging my head against the wall, I discovered EXCEL DNA, wanderfull, smoth and easy.

    thank you very much for your help.


    Tuesday, October 18, 2011 7:10 PM