views:

150

answers:

1

I'm using VSTO to automate the word Processor. code behind C#, word 2003 Addin

I notice that if I keep the font size to 11 I can split a Word Table Cell into 11 rows, but if I increase the font size it can be split into 25 rows.

Is there a way on which I can get the max split size of particular cell before executing split on it.

+1  A: 

First of all, the maximum number of column splits is 63, so you can split a cell by 62 to get that number.

Now on to the bad news - there is no programmatic way to know the maximum number of row splits allowable. Try way too many, you'll get error code 5148 (which lists an incorrect number range of allowable splits) and try just under that max range from error 5148, but above the actual allowable split, and you'll get error code 4198.

The only way to know for sure the maximum number of splits is to test this by hand, per font and per size. For example, here are the numbers for Calibri:

  • Font Size(s): 8 - 11, Max Splits: 13
  • Font Size(s): 12 - 13, Max Splits: 15
  • Font Size(s): 14, Max Splits: 17
  • Font Size(s): 15, Max Splits: 18
  • Font Size(s): 16, Max Splits: 19
  • Font Size(s): 17 - 18, Max Splits: 21
  • Font Size(s): 19, Max Splits: 23
  • Font Size(s): 20, Max Splits: 24
  • Font Size(s): 21, Max Splits: 25
  • Font Size(s): 22 - 23, Max Splits: 27
  • Etc.

To hand calculate, you need to place your cursor inside the cell you want with the font and font size you want, and then in the Split Cells dialog, run the number via the UpDownNumeric control to the max it will allow you for row splits. Your mileage will vary signficantly and even the slightest changes in the table and, weirdly enough, in the actual cell, sometimes change those max splits.

Otaku