Workbook.ReadOnlyRecommended Property (2007 System)
Gets or sets a value that indicates whether the workbook was saved as read-only recommended.
Namespace: Microsoft.Office.Tools.Excel
Assembly: Microsoft.Office.Tools.Excel.v9.0 (in Microsoft.Office.Tools.Excel.v9.0.dll)
Syntax
'Declaration
Public Property ReadOnlyRecommended As Boolean
'Usage
Dim instance As Workbook
Dim value As Boolean
value = instance.ReadOnlyRecommended
instance.ReadOnlyRecommended = value
public bool ReadOnlyRecommended { get; set; }
public:
property bool ReadOnlyRecommended {
bool get ();
void set (bool value);
}
public function get ReadOnlyRecommended () : boolean
public function set ReadOnlyRecommended (value : boolean)
Property Value
Type: System.Boolean
true if the workbook was saved as read-only recommended; otherwise, false.
Remarks
When you open a workbook that was saved as read-only recommended, Microsoft Office Excel displays a message recommending that you open the workbook as read-only.
Use the SaveAs method to change this property.
Examples
The following code example displays a message box if the ReadOnlyRecommended property is true and the ReadOnly property is false, and then prompts the user to set the file access to read-only by calling the ChangeFileAccess method.
This example is for a document-level customization.
Private Sub MakeWorkbookReadOnly()
If Me.ReadOnlyRecommended AndAlso Not Me.ReadOnly Then
' Change the access level of the document to read-only
' if the user clicks yes.
If MessageBox.Show("Set this document to read-only?", _
"Sample", MessageBoxButtons.YesNo) = DialogResult.Yes Then
Me.ChangeFileAccess(Excel.XlFileAccess.xlReadOnly, Notify:=False)
End If
End If
End Sub
private void MakeWorkbookReadOnly()
{
if (this.ReadOnlyRecommended && !this.ReadOnly)
{
// Change the access level of the document to read-only if the user
// clicks yes.
if (MessageBox.Show("Set this document to read-only?",
"Sample", MessageBoxButtons.YesNo) == DialogResult.Yes)
{
this.ChangeFileAccess(Excel.XlFileAccess.xlReadOnly,
missing, false);
}
}
}
.NET Framework Security
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.