Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 05-05-2014, 03:23 AM
macropod's Avatar
macropod macropod is offline a problem with tables, PLEASE HELP ME :/ Windows 7 32bit a problem with tables, PLEASE HELP ME :/ Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,525
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

Try:
Code:
Sub FormatTables()
' Turn Off Screen Updating
Application.ScreenUpdating = False
Dim SBar As Boolean, Rng As Range, i As Long, j As Long, TblCell As Cell
' Store current Status Bar status, then switch on
SBar = Application.DisplayStatusBar
Application.DisplayStatusBar = True
With ActiveDocument
  j = .Tables.Count
  ' Process all tables
  For i = .Tables.Count To 1 Step -1
    StatusBar = "Processing table: " & j - i + 1 & " of " & j
    With .Tables(i)
      With .Range.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Format = False
        .Forward = True
        .Wrap = wdFindStop
        .MatchWildcards = True
        .Text = "([! ])[ ]@([! ])"
        .Replacement.Text = "\1^t\2"
        .Execute Replace:=wdReplaceAll
        .Text = "[ ]@([! ])"
        .Replacement.Text = "\1"
        .Execute Replace:=wdReplaceAll
      End With
      Set Rng = .Range
      .ConvertToText Separator:=vbTab
    End With
    Rng.ConvertToTable Separator:=vbTab
    With .Tables(i)
      ' Set Autofit
      .AllowAutoFit = False
      ' Turn off text wrapping in cells
      For Each TblCell In .Range.Cells
        TblCell.WordWrap = False
      Next
      ' Reduce the cell left/right padding
      .LeftPadding = 2.5
      .RightPadding = 2.5
      With .Range
        ' Set the font point size
        .Font.Size = 13
        ' Set the space before/after
        With .ParagraphFormat
          .SpaceBefore = 0
          .SpaceAfter = 0
          .Alignment = wdAlignParagraphCenter
        End With
      End With
      ' Clear preferred dimensions
      .PreferredWidthType = wdPreferredWidthAuto
      .Columns.PreferredWidthType = wdPreferredWidthAuto
      ' Set Autofit
      .AllowAutoFit = True
    End With
    DoEvents
  Next
End With
' Clear the Status Bar
Application.StatusBar = ""
' Restore original Status Bar status
Application.DisplayStatusBar = SBar
' Turn On Screen Updating
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
a problem with tables, PLEASE HELP ME :/ Pivot table grouping problem 2 tables need different grouping differentdrummer Excel 3 12-10-2013 01:19 AM
a problem with tables, PLEASE HELP ME :/ Problem with page breaks and excel tables stu_uk Word 1 12-11-2012 02:50 PM
a problem with tables, PLEASE HELP ME :/ Problem with Tables and Templates Luxanais Word Tables 1 09-06-2011 03:42 AM
a problem with tables, PLEASE HELP ME :/ Problem with Tables and Templates Luxanais Word 1 09-04-2011 06:17 AM
a problem with tables, PLEASE HELP ME :/ Problem with joinign tables and viewing them on a mobile device alphabravo Word Tables 2 03-23-2011 09:32 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 02: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