title: How to add a DocumentProperty to CustomDocumentProperties in Excel?
body: <p>I'm trying to add a DocumentProperty to the CustomDocumentProperties collection.  Code as follows:</p>
  
  <pre><code>Sub testcustdocprop()
  Dim docprops As DocumentProperties
  Dim docprop As DocumentProperty
  
  Set docprops = ThisWorkbook.CustomDocumentProperties
  Set docprop = docprops.Add(Name:="test", LinkToContent:=False, Value:="xyz")
  
  End Sub
  </code></pre>
  
  <p>Running this gives me the following error:</p>
  
  <pre><code>Run-time error '5':
  Invalid procedure call or argument
  </code></pre>
  
  <p>I tried running it with <code>.Add</code> as a void function, like so:</p>
  
  <pre><code>docprops.Add Name:="test", LinkToContent:=False, Value:="xyz"
  </code></pre>
  
  <p>This gave me the same error.  How do I add a custom document property?</p>