Making Excel Cells Read Only
-
I have an application that creates an Excel workbook from a template. After the workbook is created I populate each Worksheet. I'm attempting to make the cells that contain headers and other data describing text read only. Here are my latest two attempts:
Worksheet ws = m\_wkbk.Sheets\[1\]; ws.Activate(); // Attempt 1 ws.Range\["A1", "E1"\].Style.Locked = true; // This runs but has no impact on the launched sheet. // Attempt 2 Range range = (Range)ws.get\_Range(ws.Cells\[1, 1\], ws.Cells\[1, 5\]); // Runtime error range.Locked = true;
-
I have an application that creates an Excel workbook from a template. After the workbook is created I populate each Worksheet. I'm attempting to make the cells that contain headers and other data describing text read only. Here are my latest two attempts:
Worksheet ws = m\_wkbk.Sheets\[1\]; ws.Activate(); // Attempt 1 ws.Range\["A1", "E1"\].Style.Locked = true; // This runs but has no impact on the launched sheet. // Attempt 2 Range range = (Range)ws.get\_Range(ws.Cells\[1, 1\], ws.Cells\[1, 5\]); // Runtime error range.Locked = true;
Excel only locks the locked cells when a password is put on the sheet. Every cell has the Locked attribute set on new sheets, you unlock cells you want to allow users to change then set a password on the sheet to protect the locked cells.
-
Excel only locks the locked cells when a password is put on the sheet. Every cell has the Locked attribute set on new sheets, you unlock cells you want to allow users to change then set a password on the sheet to protect the locked cells.
-
Excel only locks the locked cells when a password is put on the sheet. Every cell has the Locked attribute set on new sheets, you unlock cells you want to allow users to change then set a password on the sheet to protect the locked cells.
-
I have an application that creates an Excel workbook from a template. After the workbook is created I populate each Worksheet. I'm attempting to make the cells that contain headers and other data describing text read only. Here are my latest two attempts:
Worksheet ws = m\_wkbk.Sheets\[1\]; ws.Activate(); // Attempt 1 ws.Range\["A1", "E1"\].Style.Locked = true; // This runs but has no impact on the launched sheet. // Attempt 2 Range range = (Range)ws.get\_Range(ws.Cells\[1, 1\], ws.Cells\[1, 5\]); // Runtime error range.Locked = true;
-
I have an application that creates an Excel workbook from a template. After the workbook is created I populate each Worksheet. I'm attempting to make the cells that contain headers and other data describing text read only. Here are my latest two attempts:
Worksheet ws = m\_wkbk.Sheets\[1\]; ws.Activate(); // Attempt 1 ws.Range\["A1", "E1"\].Style.Locked = true; // This runs but has no impact on the launched sheet. // Attempt 2 Range range = (Range)ws.get\_Range(ws.Cells\[1, 1\], ws.Cells\[1, 5\]); // Runtime error range.Locked = true;
to make the Locked-Attribute working you have to protect your Sheet. For example :
ws.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
-
A sheet can be protected without password.
Patrice “Everything should be made as simple as possible, but no simpler.” Albert Einstein
My apologise, your right, I just never used it that way always had passwords.
-
And what is the result of this ?
ws.Range["A1", "E1"].Locked = true;
Patrice “Everything should be made as simple as possible, but no simpler.” Albert Einstein
-
to make the Locked-Attribute working you have to protect your Sheet. For example :
ws.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True