title: Generic Way to Determine the Maximum Allowed Length a of String
body: <p>Take a look at this property(Given you have a table on the first worksheet):</p>
  
  <pre><code>Application.Sheets(1).ListObjects(1).name
  </code></pre>
  
  <p>How many characters can this property contain? Well, after testing out a few strings I've come to the conclusion that its 255, any string with more than 255 characters causes an error to be thrown:</p>
  
  <blockquote>
    <p>Run-Time Error 5 - Invalid procedure call or arguement</p>
  </blockquote>
  
  <p>Take a look at this property:</p>
  
  <pre><code>Application.Sheets(1).ListObjects(1).Summary
  </code></pre>
  
  <p>How many characters can this property contain? Again, test several strings and you'll come out with a number that's around 50,000, You set it any higher and you get the same error, except in this case excel will sometimes crash or spit out a different error(after multiple attempts):</p>
  
  <pre><code>Dim i As Integer
  Dim a As String
  
  For i = 1 To 5001
      a = a &amp; "abcdefghih"
  Next i
  
  Application.Sheets(1).ListObjects(1).Summary = a
  </code></pre>
  
  <blockquote>
    <p>Method "Summary" of object 'ListObject' failed</p>
  </blockquote>
  
  <p>This sort of "hidden" character limit comes up all over the place(<a href="https://stackoverflow.com/questions/2516702/getting-around-the-max-string-size-in-a-vba-function">here</a>, <a href="http://excelribbon.tips.net/T013175_Using_Very_Long_Worksheet_Tab_Names.html" rel="nofollow noreferrer">here</a>, <a href="https://stackoverflow.com/questions/30888993/vba-unexpected-reach-of-string-size-limit">less specifically here</a>, <a href="https://stackoverflow.com/a/3681908/2912011">and so classically here</a>), and it doesn't seem like they're documented anywhere, for example take a look at the page for <a href="https://msdn.microsoft.com/en-us/library/office/ff841184.aspx" rel="nofollow noreferrer">ListObject.Name</a>, its not noted how many characters you can store in that variable...</p>
  
  <p>So is there a better way to determine this? Are the strings you are setting in properties being stored in a fixed length string somewhere that can be accessed to determine what their maximum length is, or is there some other form of documentation that can be leveraged in order to obtain this information?</p>
  
  <p>It strikes me as odd these character limits that are set on most strings within standard VBA objects, I wonder what their purpose is, why the designers choose to limit "ListObjects.name" to 255 characters and whether that was an arbitrary default limit or whether that was a conscious decision that was made. I believe that the standard string length is <a href="https://stackoverflow.com/a/10927873/2912011">this</a>, I wonder why the deviation from this standard.</p>
  
  <p>To summarize the points I've made above and to condense this question into one sentence:</p>
  
  <p>Is there a generic way to determine the maximum length of a string that can be set within an object's property, without first testing that string's property by giving it another value and ignoring errors/checking for character truncation?</p>