none
ListObject GetVstoObject buggy RRS feed

  • General discussion

  • In reference to : https://msdn.microsoft.com/en-us/library/ee248048.aspx

    If you call GetVstoObject on an Excel Interop.ListObject, you'll get a Tools.ListObject that has some extra functionality.   The Tools.ListObject wraps the Excel ListObject and provides additional functionality.   Unfortunately, one of the things it does is cache the name of the ListObject at the time that the Tools.ListObject wrapper was created and than uses that cached name every time the user saves the workbook. 

    There is *no* way to detach the internal Interop.ListObject from the Tools.ListObject that's returned by GetVstoObject.   Calling Dispose on the Tools.ListObject doesn't make a difference.

    Solutions:

    1.  Never call GetVstoObject for a ListObject if you care 

    2.   Force detach by converting the underlying Interop.ListObject into a range and then recreating the table.  Do all this outside of the Tools.ListObject namespace.   

    3.   Give the user another way to change the name of the table and update the name of the Tools.ListObject (I haven't tested this)

    I ended up simply removing the code that was using Tools.ListObject.  We were only using it for Data Binding, but that feature is limited anyway (it will not update the spreadsheet when the column list is modified, so you have to have alternate code to modify the table anyway, or recreate it each time the data-source changes).

    Tuesday, February 10, 2015 9:45 PM

All replies

  • Hi Kasajian,

    Thanks for your feedback and sharing the solutions.

    >> one of the things it does is cache the name of the ListObject at the time that the Tools.ListObject wrapper was created and then uses that cached name every time the user saves the workbook.

    What do you mean by “uses that cached name every time the user saves the workbook”?

    Regards,

    Jeffrey


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Wednesday, February 11, 2015 11:43 PM
    Moderator