![]() |
|
#1
|
|||
|
|||
![]()
Hi
I am automating case captions for legal pleadings. I have a system that does everything but ONE thing. Local court rules won't allow a vertical line. So instead of Word automatically incrementing a right border every time I enter a new line in a table cell; I need to find a way to end each line with a ")". IOW, a vertical line of right justified closed parens, one for each line in the left cell of the table. I have tried adding a narrow middle cell column in the table just to contain the ")". But can not figured how to auto add a ")" every time a line is added to the left table cell. I have also thought about trying to substitute a ")" as a custom border, but Word 2013 seems to only allow the silly baked-in graphic images as an alternative to lines for borders. Thanks in advance for taking time to help with this problem. -DL MS Office 2013 |
#2
|
||||
|
||||
![]()
Your query seems confusing about how many columns the table has and where exactly the brackets are supposed to go, but the following will insert a left bracket at the start of the row and a right bracket at the end of the row, when you tab out of the last cell in the table, thus creating a new row. Tabbing between other cells in the table, merely moves the cursor to the next cell:
Code:
Sub NextCell() 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 oTable As Table If Selection.Information(wdWithInTable) = True Then Set oTable = Selection.Tables(1) Set oRow = Selection.Rows(1) iRow = oRow.Index iCol = oRow.Cells.Count Set oCell = oTable.Cell(iRow, iCol) 'If the cursor is not in the last cell of the table, move to the next cell If Not Selection.InRange(oCell.Range) Or _ Not Selection.InRange(oTable.Rows.Last.Range) Then Selection.Cells(1).Next.Select Selection.Collapse 1 GoTo lbl_Exit End If 'Cursor is in the last cell of the table '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 'add a right bracket at the end of the cell oRng.InsertAfter vbTab & ")" 'locate the first cell in the row with the cursor Set oCell = Selection.Tables(1).Cell(iRow, 1) 'set a range to that cell Set oRng = oCell.Range 'and insert a left bracket before the cell content oRng.InsertBefore "( " 'and add a new row to the table Set oRow = oTable.Rows.Add 'select the first cell of the new row oRow.Cells(1).Select 'move the selection to the start of the cell Selection.Collapse 1 End If lbl_Exit: Set oTable = 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 |
#3
|
|||
|
|||
![]() Quote:
I know, too simple but, I had to ask. |
#4
|
|||
|
|||
![]() Quote:
Jones ) v ) <-- the parens don't align here, but should stack right aligned in the actual Word table. Smith ) Thanks for looking the question. -DL |
#5
|
||||
|
||||
![]()
OK if you only want the parenthesis in the right cell and after each paragraph there modify the previous macro as follows:
http://www.gmayor.com/installing_macro.htm Code:
Sub NextCell() 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) Set oRow = Selection.Rows(1) iRow = oRow.Index iCol = oRow.Cells.Count Set oCell = oTable.Cell(iRow, iCol) 'If the cursor is not in the last cell of the table, move to the next cell If Not Selection.InRange(oCell.Range) Or _ Not Selection.InRange(oTable.Rows.Last.Range) Then Selection.Cells(1).Next.Select Selection.Collapse 1 GoTo lbl_Exit End If 'Cursor is in the last cell of the table '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 'and add a new row to the table Set oRow = oTable.Rows.Add 'select the first cell of the new row oRow.Cells(1).Select 'move the selection to the start of the cell Selection.Collapse 1 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 |
#6
|
||||
|
||||
![]()
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 |
#7
|
|||
|
|||
![]()
Wow! That is impressive.
I will work work with your code later this week. Thank you for such a complete response. -DL |
![]() |
Tags |
border lines, legal pleading |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
vote4gop | Word | 5 | 02-28-2015 10:44 PM |
![]() |
n00bie-n00b | Word VBA | 6 | 10-08-2014 11:54 PM |
![]() |
l39linden | Word Tables | 5 | 10-04-2013 02:06 AM |
![]() |
tinfanide | Word | 4 | 10-27-2012 06:35 AM |
![]() |
msbytes | Word | 4 | 08-15-2011 09:21 AM |