views:

51

answers:

0

Hi, I have created a addin for excel, where there is a ribbon and a button on it. I have handled the event of button click with the following code

 Private Sub test_button_Click(ByVal sender As System.Object, ByVal e As Microsoft.Office.Tools.Ribbon.RibbonControlEventArgs) Handles test_button.Click

    Dim activeWorksheet As Excel.Worksheet = Globals.ThisAddIn.Application.ActiveSheet
    Dim str As String
    Dim activeWorkbook As Excel.Workbook = Globals.ThisAddIn.Application.ActiveWorkbook
    Dim sheet As Excel.Worksheet
    Dim sheet_name As String

    Globals.ThisAddIn.Application.Workbooks.Open("c:\\Test.xls")
    str = Globals.ThisAddIn.Application.ActiveWorkbook.FullName
    activeWorkbook.Save()
    Globals.ThisAddIn.Application.Workbooks.Close()

    'Call to python com object 
    Dim PythonUtils = CreateObject("PythonDemos.Utilities")
    Dim response = PythonUtils.SplitString("Hello from VB", str)
    MsgBox(response)
    Globals.ThisAddIn.Application.Workbooks.Open("c:\\Test.xls")

End Sub

When the call returns, the application open the workbook, but then after opening it, it futher proceeds to unlode the adding and the ThisAddIn_Shutdown method is called. Can anyone please help me find out as to where i am going wrong and how can i stop unloading of the excel addin?