title: Can VBA detect line-wrapping in an Excel chart legend?
body: <p><strong>Context</strong></p>
  
  <p>Writing to code to format a chart (all of which should be done by Microsoft, but that’s separate). </p>
  
  <p>Am now positioning the legend. Taking a 9×9 block of possible positions, and counting the data points underneath each. As a fragment of the code: <code>(ax.MaximumScale - ax.MinimumScale) * co.Chart.Legend.Width / co.Chart.PlotArea.InsideWidth</code>.</p>
  
  <p>Also coping with lines underlapping and text boxes overlapping the possible legend positions: same idea, more complexity. </p>
  
  <p><strong>Question</strong></p>
  
  <p>Obviously, all this works better if the legend is as small as possible, as that gives a greater likelihood of finding a location with zero ’lapping. </p>
  
  <p>If .Legend.Width is too small, then the individual legend texts (the Series.Name’s) wrap onto ≥2 lines, which isn’t wanted. So VBA could interval bisect to find the smallest .Legend.Width for which there isn’t line wrapping. But how can the VBA code ‘see’|‘detect’|‘know’ of the existence of the line wrapping? </p>
  
  <p>And <em>mutatis mutandis</em> for .Legend.Height: if that’s too small, some legend entries aren’t shown. How can the VBA code ‘see’|‘detect’|‘know’ that a height is too small?</p>
  
  <p>Thank you.</p>
  
  <p>PS: I expect that the correct answer is that “VBA cannot ‘see’|‘detect’|‘know’ either of these.” Please refute this expectation. </p>