# GrapeCity.Documents.Word.VariableCollection

## Content

<div class="doc-site-dotnet-api-container">



  <h1 id="GrapeCity_Documents_Word_VariableCollection" data-uid="GrapeCity.Documents.Word.VariableCollection" class="text-break">VariableCollection Class
</h1>
  <div class="markdown level0 summary"><p>A collection of <a class="xref" href="GrapeCity.Documents.Word.Variable.html">Variable</a> objects that represent the variables added to a document or template. Document variables are used to preserve macro settings in between macro sessions.</p>
</div>
  <div class="markdown level0 conceptual"></div>
  <div class="inheritance">
    <h5>Inheritance</h5>
    <div class="level0"><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.object">object</a></div>
    <div class="level1"><span class="xref">VariableCollection</span></div>
  </div>
  <div class="implements">
    <h5>Implements</h5>
    <div><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.collections.generic.ireadonlylist-1">IReadOnlyList</a>&lt;<a class="xref" href="GrapeCity.Documents.Word.Variable.html">Variable</a>&gt;</div>
    <div><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.collections.generic.ireadonlycollection-1">IReadOnlyCollection</a>&lt;<a class="xref" href="GrapeCity.Documents.Word.Variable.html">Variable</a>&gt;</div>
    <div><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1">IEnumerable</a>&lt;<a class="xref" href="GrapeCity.Documents.Word.Variable.html">Variable</a>&gt;</div>
    <div><a class="xref" href="https://learn.microsoft.com/dotnet/api/system.collections.ienumerable">IEnumerable</a></div>
  </div>
  <h6><strong>Namespace</strong>: <a class="xref" href="GrapeCity.Documents.Word.html">GrapeCity.Documents.Word</a></h6>
  <h6><strong>Assembly</strong>: DS.Documents.Word.dll</h6>
  <h5 id="GrapeCity_Documents_Word_VariableCollection_syntax">Syntax</h5>
  <div class="codewrapper">
    <pre><code class="lang-csharp hljs">public class VariableCollection : IReadOnlyList&lt;Variable&gt;, IReadOnlyCollection&lt;Variable&gt;, IEnumerable&lt;Variable&gt;, IEnumerable</code></pre>
  </div>
  <div class="codewrapper">
    <pre><code class="lang-vbnet hljs">Public Class VariableCollection
    Implements IReadOnlyList(Of Variable), IReadOnlyCollection(Of Variable), IEnumerable(Of Variable), IEnumerable</code></pre>
  </div>
  <h3 id="properties">Properties
</h3>
  <table class="table table-bordered table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td id="GrapeCity_Documents_Word_VariableCollection_Count" data-uid="GrapeCity.Documents.Word.VariableCollection.Count">
          <a class="xref" href="GrapeCity.Documents.Word.VariableCollection.Count.html#GrapeCity_Documents_Word_VariableCollection_Count">Count</a>
        </td>
        <td class="markdown level1 summary"><p>Returns the number of variables in the document.</p>
</td>
      </tr>
      <tr>
        <td id="GrapeCity_Documents_Word_VariableCollection_Item_System_Int32_" data-uid="GrapeCity.Documents.Word.VariableCollection.Item(System.Int32)">
          <a class="xref" href="GrapeCity.Documents.Word.VariableCollection.Item.html#GrapeCity_Documents_Word_VariableCollection_Item_System_Int32_">this[int]</a>
        </td>
        <td class="markdown level1 summary"><p>Gets a document variable at the specified index.</p>
</td>
      </tr>
      <tr>
        <td id="GrapeCity_Documents_Word_VariableCollection_Item_System_String_" data-uid="GrapeCity.Documents.Word.VariableCollection.Item(System.String)">
          <a class="xref" href="GrapeCity.Documents.Word.VariableCollection.Item.html#GrapeCity_Documents_Word_VariableCollection_Item_System_String_">this[string]</a>
        </td>
        <td class="markdown level1 summary"><p>Gets a document variable by the case-insensitive name.</p>
</td>
      </tr>
    </tbody>
  </table>
  <h3 id="methods">Methods
</h3>
  <table class="table table-bordered table-condensed">
    <thead>
      <tr>
        <th>Name</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td id="GrapeCity_Documents_Word_VariableCollection_Add_System_String_System_String_" data-uid="GrapeCity.Documents.Word.VariableCollection.Add(System.String,System.String)">
          <a class="xref" href="GrapeCity.Documents.Word.VariableCollection.Add.html#GrapeCity_Documents_Word_VariableCollection_Add_System_String_System_String_">Add(string, string)</a>
        </td>
        <td class="markdown level1 summary"><p>Adds a varibale into the document.</p>
</td>
      </tr>
      <tr>
        <td id="GrapeCity_Documents_Word_VariableCollection_Clear" data-uid="GrapeCity.Documents.Word.VariableCollection.Clear">
          <a class="xref" href="GrapeCity.Documents.Word.VariableCollection.Clear.html#GrapeCity_Documents_Word_VariableCollection_Clear">Clear()</a>
        </td>
        <td class="markdown level1 summary"><p>Removes all elements from the collection.</p>
</td>
      </tr>
      <tr>
        <td id="GrapeCity_Documents_Word_VariableCollection_Contains_System_String_" data-uid="GrapeCity.Documents.Word.VariableCollection.Contains(System.String)">
          <a class="xref" href="GrapeCity.Documents.Word.VariableCollection.Contains.html#GrapeCity_Documents_Word_VariableCollection_Contains_System_String_">Contains(string)</a>
        </td>
        <td class="markdown level1 summary"><p>Gets whether a varibale with specified name exists in the document.</p>
</td>
      </tr>
      <tr>
        <td id="GrapeCity_Documents_Word_VariableCollection_Remove_System_Int32_" data-uid="GrapeCity.Documents.Word.VariableCollection.Remove(System.Int32)">
          <a class="xref" href="GrapeCity.Documents.Word.VariableCollection.Remove.html#GrapeCity_Documents_Word_VariableCollection_Remove_System_Int32_">Remove(int)</a>
        </td>
        <td class="markdown level1 summary"><p>Removes a document variable at the specified index.</p>
</td>
      </tr>
      <tr>
        <td id="GrapeCity_Documents_Word_VariableCollection_Remove_System_String_" data-uid="GrapeCity.Documents.Word.VariableCollection.Remove(System.String)">
          <a class="xref" href="GrapeCity.Documents.Word.VariableCollection.Remove.html#GrapeCity_Documents_Word_VariableCollection_Remove_System_String_">Remove(string)</a>
        </td>
        <td class="markdown level1 summary"><p>Removes a document variable with the specified name from the collection.</p>
</td>
      </tr>
      <tr>
        <td id="GrapeCity_Documents_Word_VariableCollection_TryGetValue_System_String_GrapeCity_Documents_Word_Variable__" data-uid="GrapeCity.Documents.Word.VariableCollection.TryGetValue(System.String,GrapeCity.Documents.Word.Variable@)">
          <a class="xref" href="GrapeCity.Documents.Word.VariableCollection.TryGetValue.html#GrapeCity_Documents_Word_VariableCollection_TryGetValue_System_String_GrapeCity_Documents_Word_Variable__">TryGetValue(string, out Variable)</a>
        </td>
        <td class="markdown level1 summary"><p>Tries to get a variable by its name.</p>
</td>
      </tr>
    </tbody>
  </table>

</div>
