Exception thrown when calling Workbook.SaveAs() in Excel.Interop and C#

0

We are experiencing a production issue whereby we call an Excel Workbook's SaveAs method with a password. The exception thrown is:

The remote procedure call failed. (Exception from HRESULT: 0x800706BE)

The call is done as follows, where _ExcelPassword is the workbook's generated password and ExcelOutputPath is the location on disk the file should be written to:

workbook.SaveAs(ExcelOutputPath, XlFileFormat.xlOpenXMLWorkbook, _ExcelPassword, _ExcelPassword, false, false);

There is no issue if the file is saved without a password though.

What am I missing please?

c#
excel
office-interop
office-automation

1 Answer

0

So the solution I ended up with was to save the workbook without a password, reopen it again, set the password on the workbook object and then save it again. Tedious, I know, but that completely fixed the remote procedure call failed issue I was getting

answered on Stack Overflow Nov 10, 2016 by Rudolf Lamprecht

User contributions licensed under CC BY-SA 3.0