View Single Post
 
Old 03-08-2015, 10:43 PM
gmayor's Avatar
gmayor gmayor is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,137
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

The previous macro runs the process as you tab out of the last cell of the table. The following macro run from a button or keyboard shortcut http://www.gmayor.com/installing_macro.htm will add a right tab to each right cell of the current table and add the parenthesis to each paragraph in each right cell.

You can modify one or other macro to give the results you need:
Code:
Sub AddRightTab()
Dim iWidth As Long
Dim iCol As Long
Dim iRow As Long
Dim oRow As Row
Dim oRng As Range
Dim oCell As Cell
Dim oPara As Paragraph
Dim rPara As Range
Dim oTable As Table

    If Selection.Information(wdWithInTable) = True Then
        Set oTable = Selection.Tables(1)
        For Each oRow In oTable.Rows
            iRow = oRow.Index
            iCol = oRow.Cells.Count
            Set oCell = oTable.Cell(iRow, iCol)
            'Locate the end of the cell range
            iWidth = oCell.Width - 12
            'and add a right aligned tab
            oCell.Range.ParagraphFormat.TabStops.Add _
                    Position:=iWidth, _
                    Alignment:=wdAlignTabRight, _
                    Leader:=wdTabLeaderSpaces
            'set a range to the cell with the cursor
            Set oRng = oCell.Range
            'remove the end of cell character
            oRng.End = oRng.End - 1
            For Each oPara In oRng.Paragraphs
                'add a right bracket at the end of each paragraph in the Right cell
                Set rPara = oPara.Range
                rPara.End = rPara.End - 1
                rPara.InsertAfter vbTab & ")"
            Next oPara
        Next oRow
    End If
lbl_Exit:
    Set oTable = Nothing
    Set oPara = Nothing
    Set oRow = Nothing
    Set oCell = Nothing
    Set oRng = Nothing
    Exit Sub
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote