View Single Post
 
Old 04-30-2012, 12:27 AM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,363
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 umesh,

Try:
Code:
Sub FormatTables()
Application.ScreenUpdating = False
Dim oTbl As Table, oCel As Cell, Rng As Range, i As Long
With ActiveDocument
  For Each oTbl In .Tables
    On Error Resume Next
    With oTbl
      For i = .Rows.Count To 1 Step -1
        With .Rows(i)
          If .Cells.Count > 1 Then
            Set Rng = .Range
            If FindText(Rng, "/%") = True Then .Delete
            If FindText(Rng, "<[0-9]{1,2} [JFMASOND][anebrpyulgctov]{2} [0-9]{2}>") = True Then .Delete
            If FindText(Rng, "<[Aa][Gg][Ee]>") = True Then .Delete
            If FindText(Rng, "[A-Za-z0-9]") = False Then .Delete
            Rng.Start = .Cells(2).Range.Start
            If FindText(Rng, "[!0]") = False Then .Delete
          End If
        End With
      Next
      For Each oCel In .Range.Cells
        Set Rng = oCel.Range
        With Rng
          .End = .End - 1
          If IsNumeric(.Text) Then .Text = Format(.Text, "$#,##0")
        End With
      Next
      With .Range.Find
        .ClearFormatting
        .Replacement.ClearFormatting
        .Forward = True
        .Wrap = wdFindStop
        .Format = False
        .MatchAllWordForms = False
        .MatchSoundsLike = False
        .MatchWildcards = True
        .Text = "\<[ ]@"
        .Replacement.Text = "<"
        .Execute Replace:=wdReplaceAll
        .Text = "[ ]@\<"
        .Replacement.Text = "<"
        .Execute Replace:=wdReplaceAll
        .Text = "\<"
        .Replacement.Text = "     "
        .Execute Replace:=wdReplaceAll
      End With
      .Range.Font.Size = 9
      .TopPadding = 5
      .BottomPadding = 2
    End With
  Next
End With
Application.ScreenUpdating = True
End Sub
 
Function FindText(Rng As Range, StrFnd As String) As Boolean
With Rng.Find
  .ClearFormatting
  .Replacement.ClearFormatting
  .Forward = True
  .Wrap = wdFindStop
  .Format = False
  .MatchAllWordForms = False
  .MatchSoundsLike = False
  .MatchWildcards = True
  .Text = StrFnd
  .Replacement.Text = ""
  .Execute
End With
FindText = Rng.Find.Found
End Function
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote