# GrapeCity.Documents.Excel.Workbook.Protect

## Content

<div class="doc-site-dotnet-api-container">



<h1 id="GrapeCity_Documents_Excel_Workbook_Protect_" data-uid="GrapeCity.Documents.Excel.Workbook.Protect*">Protect Method
</h1>
<div class="markdown level0 summary"></div>
<div class="markdown level0 conceptual"></div>



<a id="GrapeCity_Documents_Excel_Workbook_Protect_" data-uid="GrapeCity.Documents.Excel.Workbook.Protect*"></a>
<h4 id="GrapeCity_Documents_Excel_Workbook_Protect_System_Boolean_System_Boolean_" data-uid="GrapeCity.Documents.Excel.Workbook.Protect(System.Boolean,System.Boolean)">Protect(bool, bool)</h4>
<div class="markdown level1 summary"><p>Protects a workbook so that it cannot be modified.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void Protect(bool structure = true, bool windows = false)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Sub Protect(Optional [structure] As Boolean = True, Optional windows As Boolean = False)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></td>
      <td><span class="parametername">structure</span></td>
      <td><p>True to protect the structure of the workbook (To prevent other users from viewing hidden worksheets, adding, moving, deleting, or hiding worksheets, and renaming worksheets).</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></td>
      <td><span class="parametername">windows</span></td>
      <td><p>True to prevent users from moving, resizing, or closing the workbook window, or hide/unhide windows. This option is available only in Excel 2007, Excel 2010, Excel for Mac 2011, and Excel 2016 for Mac.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="implements">Implements</h5>
    <div><a class="xref" href="GrapeCity.Documents.Excel.IWorkbook.Protect.html#GrapeCity_Documents_Excel_IWorkbook_Protect_System_Boolean_System_Boolean_">IWorkbook.Protect(bool, bool)</a></div>


<a id="GrapeCity_Documents_Excel_Workbook_Protect_" data-uid="GrapeCity.Documents.Excel.Workbook.Protect*"></a>
<h4 id="GrapeCity_Documents_Excel_Workbook_Protect_System_String_System_Boolean_System_Boolean_" data-uid="GrapeCity.Documents.Excel.Workbook.Protect(System.String,System.Boolean,System.Boolean)">Protect(string, bool, bool)</h4>
<div class="markdown level1 summary"><p>Protects a workbook so that it cannot be modified.</p>
</div>
<div class="markdown level1 conceptual"></div>
<h5 class="declaration">Declaration</h5>
<div class="codewrapper">
  <pre><code class="lang-csharp hljs">public void Protect(string password, bool structure = true, bool windows = false)</code></pre>
</div>
<div class="codewrapper">
  <pre><code class="lang-vbnet hljs">Public Sub Protect(password As String, Optional [structure] As Boolean = True, Optional windows As Boolean = False)</code></pre>
</div>
<h5 class="parameters">Parameters</h5>
<table class="table table-bordered table-condensed">
  <thead>
    <tr>
      <th>Type</th>
      <th>Name</th>
      <th>Description</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.string">string</a></td>
      <td><span class="parametername">password</span></td>
      <td><p>Password to protect the workbook.</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></td>
      <td><span class="parametername">structure</span></td>
      <td><p>True to protect the structure of the workbook (To prevent other users from viewing hidden worksheets, adding, moving, deleting, or hiding worksheets, and renaming worksheets).</p>
</td>
    </tr>
    <tr>
      <td><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.boolean">bool</a></td>
      <td><span class="parametername">windows</span></td>
      <td><p>True to prevent users from moving, resizing, or closing the workbook window, or hide/unhide windows. This option is available only in Excel 2007, Excel 2010, Excel for Mac 2011, and Excel 2016 for Mac.</p>
</td>
    </tr>
  </tbody>
</table>
<h5 class="implements">Implements</h5>
    <div><a class="xref" href="GrapeCity.Documents.Excel.IWorkbook.Protect.html#GrapeCity_Documents_Excel_IWorkbook_Protect_System_String_System_Boolean_System_Boolean_">IWorkbook.Protect(string, bool, bool)</a></div>
</div>
