Using the interop classes in C# I was able to protect a workbook for reading and writing with a password.
But I want users to be able to open the sheet as read-only.
Is this possible without using the Workbook.SaveAs
method?
Protecting a workbook with a password (picture 1) I'm using the Workbook.Password
property.
According to MSDN, the only way to change the
Workbook.ReadOnlyRecommended
property is with theWorkbook.SaveAs
method.In needed precisely what you're looking for a while ago (i.e. setting it without saving), but had to give in and use
SaveAs
. To my knowledge it's the only way.Use
Workbook.Open()
. The 3rd parameter is the read only property.Plus a link to to the MSDN