View Single Post
 
Old 11-03-2015, 04:32 PM
macropod's Avatar
macropod macropod is online now Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,467
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

If you're trying to simulate hidden columns, a better way than changing the font size & colour would be to hide the content and to minimize the relevant column widths. For example:
Code:
Sub FormatTables()
Application.ScreenUpdating = False
Dim Stl As Style, bStlA As Boolean, bStlB As Boolean, Tbl As Table, i As Long, j As Long, ArrCols
bStlA = False: bStlB = False
ArrCols = Array("2", "5", "8", "11")
With ActiveDocument
  For Each Stl In .Styles
    If Stl.NameLocal = "TblGhost" Then bStlA = True
    If Stl.NameLocal = "TblTxt" Then bStlB = True
  Next
  If bStlA = False Then Call AddStyle("TblGhost", True)
  If bStlB = False Then Call AddStyle("TblTxt", False)
  For Each Tbl In .Tables
    With Tbl
      .AllowAutoFit = False
      .LeftPadding = 0
      .RightPadding = 0
      .Range.Style = "TblGhost"
      With .Columns
        .Borders.Enable = False
        .PreferredWidthType = wdPreferredWidthPoints
        .PreferredWidth = 0
      End With
      For i = 0 To UBound(ArrCols)
        If ArrCols(i) > .Columns.Count Then Exit For
        With .Columns(ArrCols(i))
          .PreferredWidth = 150
          .Borders.Enable = True
          For j = 1 To .Cells.Count
            .Cells(j).Range.Style = "TblTxt"
          Next
        End With
      Next
    End With
  Next
End With
Application.ScreenUpdating = True
End Sub
 
Sub AddStyle(strNm As String, bHidden)
Dim Sty As Style
With ActiveDocument
  Set Sty = .Styles.Add(Name:=strNm, Type:=wdStyleTypeParagraph)
  With Sty
    With .Font
      .Hidden = bHidden
      .Size = 12
    End With
  End With
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote