A
ArchieDog via OfficeKB.com
Hi All
I am trying to modify a table style using the code below:
Sub Set_Padding()
Dim styTable As Style
Set styTable = ActiveDocument.Styles("My Table Style")
With styTable.Table
.TopPadding = InchesToPoints(0.08)
.BottomPadding = InchesToPoints(0.08)
.LeftPadding = InchesToPoints(0.08)
.RightPadding = InchesToPoints(0.08)
End With
End Sub
If I create a table based on the specific table style (My Table Style) the
table looks as I want it to - the code appears to have worked. However, if I
go into the style's properties (as though intending to modify it), or if I
look at the table's properties (Tables, Table Properties, Options) the
default cell margins have not changed - it remains at whatever was set before
the code was run.
If I run the code again to make further changes - e.g. change the values for
the cell padding - eventually it all goes very, very wrong indeed with the
table appearance changing to something not asked for and the style/table
properties for default cell margins never changing.
The code appears to work in that the end result is as required but I need it
to correctly update the style's properties.
Can anyone tell me what I'm missing, please? I'm sure it must be something
obvious. By the way, I am using Word 2003 SP2.
Many thanks.
ArchieDog
I am trying to modify a table style using the code below:
Sub Set_Padding()
Dim styTable As Style
Set styTable = ActiveDocument.Styles("My Table Style")
With styTable.Table
.TopPadding = InchesToPoints(0.08)
.BottomPadding = InchesToPoints(0.08)
.LeftPadding = InchesToPoints(0.08)
.RightPadding = InchesToPoints(0.08)
End With
End Sub
If I create a table based on the specific table style (My Table Style) the
table looks as I want it to - the code appears to have worked. However, if I
go into the style's properties (as though intending to modify it), or if I
look at the table's properties (Tables, Table Properties, Options) the
default cell margins have not changed - it remains at whatever was set before
the code was run.
If I run the code again to make further changes - e.g. change the values for
the cell padding - eventually it all goes very, very wrong indeed with the
table appearance changing to something not asked for and the style/table
properties for default cell margins never changing.
The code appears to work in that the end result is as required but I need it
to correctly update the style's properties.
Can anyone tell me what I'm missing, please? I'm sure it must be something
obvious. By the way, I am using Word 2003 SP2.
Many thanks.
ArchieDog