title: How do I read the formatted textual representation of a cell in Excel
body: <p>I'm using the COM interface to Excel and I would like to get hold of the formatted textual representation of a cell rather than the true underlying value.</p>
  
  <p>For example, suppose the cell contains the number <code>1.23456</code> and the user has specified the number format with 1 decimal place.  Then I'd like to be able to read the string <code>"1.2"</code>.  I know that I can use <code>Range.Text</code> but this fails in a couple of significant ways.  <code>Range.Text</code> returns what the user sees in the view of the sheet and so if the cell is hidden then the empty string is returned.  If the cell's width is low then a truncated string is returned.  <code>Range.Text</code> also falls down because it is limited to 1024 characters.</p>
  
  <p>Another use case is when the cell evaluates to an error, e.g. <code>#DIV/0!</code>, <code>#NAME?</code>, <code>#REF!</code> etc.  I know that I can read <code>Range.Value</code> and test if the variant is type <code>varError</code> (I'm using Delphi, in VBA it would be <code>vbError</code>).  What I can't figure out is how to get hold of the text representation <code>#DIV/0!</code> etc.  Again <code>Range.Text</code> returns this, but not if the cell is hidden or is too narrow.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I think that the limit on Range.Text is actually 255 characters.</p>