none
Memory issue with Excel 2013/2016/2019 (32bit), Excel 2007 works fine. RRS feed

  • Question

  • Hello,

    I'm trying to open ~300-500 Excel files(.xlsx) and getting Error Workbooks.open method failed. I'm opening file, reading cells, writing back and closing it. Excel files around 25-60Kb size only. Problem comes with error that says workbooks.open method failed. I've noticed that on Excel 2013-2019 after I'm doing Workbooks.Open Excel reserves memory for around 2-5MB, when VSTO Add-In memory reaches ~600+MB, Excel throws that error and i can't do anything. I've tried to rework method for opening files, also release every object after each open file then make GC.Collect and GC.WaitForPendingFinalizers, but overall it does not help, memory is growing up until crash. BUT if my VSTO Add-In runes on Excel 2007 - it's all fine, Excel at some point releasing memory and I don't receive error. Can anyone help?

    I've adding below my workbooks.open call. Also i tried for example different way: var op = Globals.ThisAddIn.Application; op.Display.... op.Workbooks.Open... and then op = null, and call GC 4 times, but no use.

    public static void opend(string path, bool ll = true, bool bb = true)
            {
                try
                {
                    Globals.ThisAddIn.Application.DisplayAlerts = false;
                    Globals.ThisAddIn.Application.Workbooks.Open(path, ll, bb);
                    Globals.ThisAddIn.Application.DisplayAlerts = true;
                }
                catch (Exception ex)
                {
                    ThisAddIn.Klaida2(ex.ToString());
                }
            }


    • Edited by Vytautas A Friday, May 3, 2019 7:28 AM
    Friday, May 3, 2019 5:46 AM