Here's a function that will tidy up a table after editing.

From time to time, cells get out of alignment and I want quickly to align the cells. Or else I've glued two tables together and want the columns to be aligned.

I call this function from a simple cover function, which I place on the toolbar as a macro command.

<pre>Public Function boolTableRebuild(Optional intSeparator)
' Procedure : boolTableRebuild
' Description: Rebuild a table from an optional paramater.
' Copyright: Chris Greaves Inc.
' Inputs: Optional VBA constant data type.
' Returns: TRUE if selection was in table (and the function could operate).
' Assumes: None.
' Side Effects: Page formatting may change.
' Tested: By the calls shown below.
Dim intSeparatorType As Integer
If IsMissing(intSeparator) Then ' We default to Tabs as separator
intSeparatorType = wdSeparateByTabs
If IsNumeric(intSeparator) Then
intSeparatorType = intSeparator
intSeparatorType = wdSeparateByTabs
End If
End If
If Selection.Information(wdWithInTable) Then ' We have a job to do.
boolTableRebuild = True
Selection.Rows.ConvertToText Separator:=intSeparatorType
Selection.ConvertToTable Separator:=intSeparatorType
boolTableRebuild = False ' No table selected returns FALSE/Failure.
End If
'Sub TESTboolTableRebuild()
' MsgBox boolTableRebuild
' MsgBox boolTableRebuild(wdSeparateByCommas)
' MsgBox boolTableRebuild(wdSeparateByTabs)
'End Sub
End Function