T
Tony Jollans
In the course of trying to help someone on another forum, I have been looking
at Table AutoFormats vs Table Styles and there seem to be some aspects that
don't work properly. I have searched everywhere I know to search and found NO
information at all; perhaps I'm just missing the glaringly obvious.
There used to be a Table AutoFormat feature that applied a pre-defined set
of formatting to a table. When you used it, it set various Properties of the
Table Object (AutoFormatType, ApplyStyleHeadingRos, etc.) which could be
referenced in VBA. It may not have been perfect but it did a job and you more
or less knew where you stood with it. The same feature still exists in Word
2003 (albeit slightly hidden) and still appears to do the same; it doesn't
interact with Table Styles at all.
In Word 2003 (and XP I suppose but I tested in 2K3) there are Table Styles.
There is still a "Table AutoFormat" menu option but it runs the
TableAutoFormatStyle Dialog (which, like the old version, has a Title of
"Table AutoFormat"). The only effect this feature has on the old Table
Properties is that, when you apply a (new format) Style, the AutoFormatType
is set to a value of 1 (wdTableFormatSimple1), and the
..ApplyStyleHeadingRows, etc. properties are set according to the boxes
checked (and acted upon) in the dialog. If you record this action you will
get something along the lines of the following code:
With Selection.Tables(1)
.Style = "Table Grid 4"
.ApplyStyleHeadingRows = True
.ApplyStyleLastRow = True
.ApplyStyleFirstColumn = True
.ApplyStyleLastColumn = False
End With
which is exactly the same as the code example in the Help files. This code,
however, does not carry out the action carried out by the dialog.
If, after doing this, you invoke the old AutoFormat Dialog it shows the
Format as being "Simple 1" along with whatever special formats you previously
applied to the Style. If you go one step further and actually apply an
AutoFormat it does it 'correctly' in as much as the format is applied to the
Table, but it does it by applying the formatting on top of the existing Style
so the Table retains the Style but no longer has the characteristics of the
Style. If you then return to the new dialog it shows the Table as being in
the Style previously set in the new dialog but with the various .Apply...
properties reflecting the action taken in the old dialog.
All this might be no more than a bit of light entertainment, but the real
problem comes when you try to work with the table format in code. It seems
nigh impossible to determine, for sure, what formats a table actually has. If
the AutoFormatType is not 1 then it (probably) correctly reflects the table
and this will (probably) be true for documents created in Word 2000. If the
AutoFormatType is 1 and the table has a non-default style then you can (again
probably) infer that the table has been formatted in XP or 2003 and the Style
is the one which has been used, but it all seems a bit hit and miss.
Is there something obvious I'm not seeing here?
at Table AutoFormats vs Table Styles and there seem to be some aspects that
don't work properly. I have searched everywhere I know to search and found NO
information at all; perhaps I'm just missing the glaringly obvious.
There used to be a Table AutoFormat feature that applied a pre-defined set
of formatting to a table. When you used it, it set various Properties of the
Table Object (AutoFormatType, ApplyStyleHeadingRos, etc.) which could be
referenced in VBA. It may not have been perfect but it did a job and you more
or less knew where you stood with it. The same feature still exists in Word
2003 (albeit slightly hidden) and still appears to do the same; it doesn't
interact with Table Styles at all.
In Word 2003 (and XP I suppose but I tested in 2K3) there are Table Styles.
There is still a "Table AutoFormat" menu option but it runs the
TableAutoFormatStyle Dialog (which, like the old version, has a Title of
"Table AutoFormat"). The only effect this feature has on the old Table
Properties is that, when you apply a (new format) Style, the AutoFormatType
is set to a value of 1 (wdTableFormatSimple1), and the
..ApplyStyleHeadingRows, etc. properties are set according to the boxes
checked (and acted upon) in the dialog. If you record this action you will
get something along the lines of the following code:
With Selection.Tables(1)
.Style = "Table Grid 4"
.ApplyStyleHeadingRows = True
.ApplyStyleLastRow = True
.ApplyStyleFirstColumn = True
.ApplyStyleLastColumn = False
End With
which is exactly the same as the code example in the Help files. This code,
however, does not carry out the action carried out by the dialog.
If, after doing this, you invoke the old AutoFormat Dialog it shows the
Format as being "Simple 1" along with whatever special formats you previously
applied to the Style. If you go one step further and actually apply an
AutoFormat it does it 'correctly' in as much as the format is applied to the
Table, but it does it by applying the formatting on top of the existing Style
so the Table retains the Style but no longer has the characteristics of the
Style. If you then return to the new dialog it shows the Table as being in
the Style previously set in the new dialog but with the various .Apply...
properties reflecting the action taken in the old dialog.
All this might be no more than a bit of light entertainment, but the real
problem comes when you try to work with the table format in code. It seems
nigh impossible to determine, for sure, what formats a table actually has. If
the AutoFormatType is not 1 then it (probably) correctly reflects the table
and this will (probably) be true for documents created in Word 2000. If the
AutoFormatType is 1 and the table has a non-default style then you can (again
probably) infer that the table has been formatted in XP or 2003 and the Style
is the one which has been used, but it all seems a bit hit and miss.
Is there something obvious I'm not seeing here?