Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #6  
Old 11-03-2015, 04:32 PM
macropod's Avatar
macropod macropod is offline 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
 

Tags
table, vba



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to apply formatting(color & shading) to specific letters in whole doc. (arabic) loopseye Word 3 08-05-2013 10:49 PM
How to set a custom border width in Word 2011 for Mac kchappell Word 0 11-10-2012 11:59 AM
Apply font color programatically using VBA Word divakarganta Word VBA 3 08-08-2012 08:05 PM
Formatting multiple tables and columns efficiently? table_column Word Tables 1 07-02-2012 05:55 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:30 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft