Click here to Skip to main content
15,889,462 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have opened Excel file in my C# Winform Application adding reference to Microsoft.Office.Interop.Excel.dll and using DSO FRAMER CONTROL.But i want to open my excel file with read only protection.I have sucessfully done this for WORD Application like this

C#
Microsoft.Office.Interop.Word.Document wordDoc =  (Microsoft.Office.Interop.Word.Document)axFramerControl1.ActiveDocument;
Microsoft.Office.Interop.Word.Application wordApp = wordDoc.Application;
wordDoc.Protect(Microsoft.Office.Interop.Word.WdProtectionType.wdAllowOnlyReading);


In the same i want to do this work for Excel.But i couldn't able to protect Excel file on that way.

C#
string path = "C:\\test-wb.xlsx";
 axFramerControl1.Open(path, true,"excel.sheet", "", "");
 Microsoft.Office.Interop.Excel._Workbook excelDoc   =(Microsoft.Office.Interop.Excel._Workbook)axFramerControl1.ActiveDocument;
        Microsoft.Office.Interop.Excel.Application excelApp =excelDoc.Application;
//What code should i write to protect Excel Workbook with read - only.
       excelDoc.Protect(misval, true, misval);//It is not working.


Please Enlighten me on this...

Thanks & Regards,
P.SARAVANAN
Posted
Updated 17-Jan-12 23:59pm
v2

1 solution

Your question has been answered on stackoverflow: Answer on stackoverflow[^]

Answer:

Quote:
Call theOpen method with third parameter (ReadOnly) = true.

See MSDN documentation :Workbooks.Open Method [^]

ReadOnly
Optional Object. True to open the workbook in read-only mode.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900