Hi folks,
currently I stuck in the following problem and I need your help here please.
But first let me explain it:
I have an Excel Workbook where most Cells are read-only and locked with a password. You can open the workbook and edit some cells, exept from the read-only cells.
My application now should go through this excel file and search a specific string and replace it with another string.
The string, what I'm searching for is always in the writable cells. Never in the read-only cells. So opening the workbook, search for those strings and replace them, should easily happen without the need of the password.
But this did not work. So I thought, ok, just let me enter the password and add it in the code:
Excel.Application xlApp = new Excel.Application();
Excel.Workbook xlWorkBook;
xlWorkBook = xlApp.Workbooks.Open(filePath.ToString(), 0, false, 5, "myPassword", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
But this also doesn't work. I'm getting something like:
"The command cannot be applied to a protected sheet."
So, how could I achieve this; to edit a protected workbook and save the changes. If possible I would appreciate if the saved workbook will also got some read-only (protected) cells?
Thanks in advance
Max