Mike Clayton
2009-07-30 17:10:01 UTC
Hi All,
I'm currently writing a VBA macro for applying some formatting to table
borders and it all more or less works, but I've hit a bit of a strange
problem in Word 2003 that I can't seem to work out.
Basically, if you create a duplicate of an existing table by ctrl-dragging
the "Table Select" icon in the top left corner of a table, then the top
border of the new table and the bottom border of the original table seem to
be linked somehow. This means that any formatting you apply to the top row of
the duplicate table also applies to the bottom of the original table.
To reproduce:
+ Create a new blank document and insert a new table.
+ Click anywhere in the table to display the "Table Select" icon in the top
left corner of it.
+ Hold down the ctrl key and drag the Table Select icon to create a
duplicate table.
+ In the VBA "Immediate" window run the following line of code:
Word.Application.ActiveDocument.Tables(2).Cell(1,1).Borders(wdBordertop).Visible = False
The top border of the top left cell in the duplicate table disappears, but
the bottom border of the bottom left cell in the original table disappears as
well. The same thing happens if you format the duplicate table's top-left
cell border using "Format -> Borders and Shading..." and change the "Apply
to" dropdown to "Cell".
Does anyone know how to either stop this happening by "unlinking" the
tables, or detect whether a given table is "linked" to the bottom of another
one?
I've been bashing my head against this for a few hours now so any help would
be greatly appreciated.
Thanks,
Mike
I'm currently writing a VBA macro for applying some formatting to table
borders and it all more or less works, but I've hit a bit of a strange
problem in Word 2003 that I can't seem to work out.
Basically, if you create a duplicate of an existing table by ctrl-dragging
the "Table Select" icon in the top left corner of a table, then the top
border of the new table and the bottom border of the original table seem to
be linked somehow. This means that any formatting you apply to the top row of
the duplicate table also applies to the bottom of the original table.
To reproduce:
+ Create a new blank document and insert a new table.
+ Click anywhere in the table to display the "Table Select" icon in the top
left corner of it.
+ Hold down the ctrl key and drag the Table Select icon to create a
duplicate table.
+ In the VBA "Immediate" window run the following line of code:
Word.Application.ActiveDocument.Tables(2).Cell(1,1).Borders(wdBordertop).Visible = False
The top border of the top left cell in the duplicate table disappears, but
the bottom border of the bottom left cell in the original table disappears as
well. The same thing happens if you format the duplicate table's top-left
cell border using "Format -> Borders and Shading..." and change the "Apply
to" dropdown to "Cell".
Does anyone know how to either stop this happening by "unlinking" the
tables, or detect whether a given table is "linked" to the bottom of another
one?
I've been bashing my head against this for a few hours now so any help would
be greatly appreciated.
Thanks,
Mike