0

I am trying to add a worksheet to a workbook and it works fine for a .XLSX file. But for a .XLSM file - I get the dreaded COMException 0x800A03EC.

I have tried all of the following and all fail:

wrkbk.Worksheets.Add(Type.Missing, Type.Missing, Type.Missing, Type.Missing);
wrkbk.Worksheets.Add(wrkbk.Worksheets[wrkbk.NativeWorkbook.Worksheets.Count], Type.Missing, Type.Missing, Type.Missing);
wrkbk.Worksheets.Add(Type.Missing, wrkbk.Worksheets[wrkbk.NativeWorkbook.Worksheets.Count], Type.Missing, Type.Missing);

Questions 1, 2, & 3 suggest the above, but it doesn't work, for me at least, with a .XLSM file.

David Thielen
  • 28,723
  • 34
  • 119
  • 193

1 Answers1

0

This is failing because the workbook is locked. A locked workbook cannot have worksheets added to it.

David Thielen
  • 28,723
  • 34
  • 119
  • 193