View Single Post
 
Old 09-30-2014, 09:21 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,366
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 RemoveSpaces()
    Dim oTable As Table, acell As Cell, oRng As Range
    For Each oTable In ActiveDocument.Tables
        With oTable
            For Each acell In oTable.Range.Cells
                Set oRng = acell.Range
                With oRng
                  .End = .End - 1
                  While .Characters.Last = " "
                    .Characters.Last = ""
                  Wend
                  While .Characters.First = " "
                    .Characters.First = ""
                  Wend
                End With
            Next acell
        End With
    Next oTable
End Sub
PS: When posting code, please use the code tags. They're on the 'Go Advanced' tab at the bottom of this screen. Your post tried to replicate them as <CODE></CODE>, whereas the tags here use [ and ] instead of < and >.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote