Thread: [Solved] Problem with Cell Margins
View Single Post
 
Old 05-08-2011, 01:26 AM
macropod's Avatar
macropod macropod is offline Windows 7 32bit Office 2007
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,962
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi Aston,

Although the various 'currency' cells in your table have a "Table numbers1" Style attached to them, it look like someone has been manually overriding that. Some of the 'currency' cells also have a different top/bottom padding than other 'currency' cells and the table defaults. It's these two things together that seem to be messing up the formatting. The following macro goes through all the cells with the "Table numbers1" Style attached, in all tables in the document, and re-formats them with the "Table numbers1" Style correctly applied and the cell padding the same as the table generally:
Code:
Sub FixTables()
Dim Tbl As Table, oCel As Cell, Rng As Range, bBld As Boolean
With ActiveDocument
  For Each Tbl In .Tables
    For Each oCel In Tbl.Range.Cells
      With oCel
        If .Range.Style = "Table numbers1" Then
          bBld = .Range.Font.Bold
          .TopPadding = Tbl.TopPadding
          .BottomPadding = Tbl.BottomPadding
          .RightPadding = Tbl.RightPadding
          .LeftPadding = Tbl.LeftPadding
          .Range.Style = "Table numbers1"
          .Range.Font.Bold = bBld
        End If
      End With
    Next
  Next
End With
End Sub
Note: the code captures and re-applies the font bolding for the cells concerned. If a 'bold' character Style had been applied to these cells, that wouldn't be necessary.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote