![]() |
#1
|
|||
|
|||
![]()
Hi,
I am trying to put together a Word minutes template for my office, and people have complained that the 'Action' doesn't line up with the 'Action Owner' and 'Deadline' columns in the table, as the 'Item' above the 'Action' has different line heights depending on whether there has been a carriage return or the text has just run on to the next line. This means that when you press enter in the other columns to try and make the 'Owner' and 'Deadline' line up you have to do a soft return to make it work, which is then out of line again if anything is added to the item. I suggested putting the 'Action' in a different row to the 'Item', but this is not popular as it looks messy and separates the different parts of the section. I have managed to make it look neater and still be functional by making the row border above the 'Action' row white, but this is too complicated and long-winded for most people to add themselves, so I was wondering if there was a way of adding formatting to the text style for the 'Action' heading that automatically inserts it in a new row with a white top border. Currently the only solution anyone has come up with is to add the 'Item' and 'Action' rows together to be inserted as a Quick Part, but I think this would also be too complicated for people to use. Any ideas? |
#2
|
||||
|
||||
![]()
Can you post a sample of what you envisage as it is difficult to understand what you are trying to do (and post a sample of the original which illustrates the alignment problem there) . It should be possible to fix with a macro.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
|||
|
|||
![]()
Thanks - here are two documents showing the problem and the solution that I want to automate
|
#4
|
||||
|
||||
![]()
Hmmm. Going with your suggestion of using autotext, save your document as a macro enabled template, then select the bottom two rows of your second table, press ALT+F3 and save as an autotext entry called ItemAction in the template.
The following macro will then add the autotext entry to the bottom of the table when you tab out of the last cell (the first table should still tab normally) as should tabbing between other cells. There is some anomaly related to bullets, when you add text to the cells just added, but the basic issue of ease of use for your users is resolved. Code:
Option Explicit 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.InRange(ActiveDocument.Tables(2).Range) Then Set oTable = ActiveDocument.Tables(2) 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 On Error GoTo lbl_Exit 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 Set oRng = oTable.Range oRng.Collapse 0 Application.Templates(ThisDocument.FullName). _ BuildingBlockEntries("ItemAction").Insert _ Where:=oRng, _ RichText:=True Set oRow = oTable.Rows.Last.Previous oRow.Cells(2).Range.ListFormat.RemoveNumbers NumberType:=wdNumberParagraph oRow.Cells(3).Range.ListFormat.RemoveNumbers NumberType:=wdNumberParagraph 'select the first cell of the new row oRow.Cells(1).Select 'move the selection to the start of the cell Selection.Collapse 1 Set oRow = oTable.Rows.Last oRow.Cells(1).Range.Paragraphs(1).Range.ListFormat.RemoveNumbers NumberType:=wdNumberParagraph oRow.Cells(2).Range.ListFormat.RemoveNumbers NumberType:=wdNumberParagraph oRow.Cells(3).Range.ListFormat.RemoveNumbers NumberType:=wdNumberParagraph Else Set oRow = Selection.Rows(1) iRow = oRow.Index iCol = oRow.Cells.Count Set oCell = Selection.Tables(1).Cell(iRow, iCol) If Not Selection.InRange(oCell.Range) Or _ Not Selection.InRange(Selection.Tables(1).Rows.Last.Range) Then Selection.Cells(1).Next.Select Selection.Collapse 1 GoTo lbl_Exit Else Set oRow = Selection.Tables(1).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 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 |
#5
|
|||
|
|||
![]()
Thanks Graham - that was almost perfect! The right border doesn't quite line up with the row above when you add the new row. I have attached what I mean. The bullets seem to be fine tho!
|
#6
|
||||
|
||||
![]()
OK no problem. Locate the two lines
Code:
oRow.Cells(3).Range.ListFormat.RemoveNumbers NumberType:=wdNumberParagraph Code:
oRow.Cells(1).Width = oTable.Rows(2).Cells(1).Width oRow.Cells(2).Width = oTable.Rows(2).Cells(2).Width oRow.Cells(3).Width = oTable.Rows(2).Cells(3).Width
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#7
|
|||
|
|||
![]()
Thank you Graham you are amazing!!
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
dylansmith | Excel | 9 | 05-16-2014 07:25 PM |
Can't change color of text in table style | ABode | Word | 6 | 12-03-2013 07:45 AM |
How to change style of text in table? | SCMiller | Word VBA | 1 | 04-24-2012 08:31 AM |
Matching text style to drawing object style | notarichman | PowerPoint | 0 | 03-07-2011 11:34 AM |
Adding a paragraph mark by style? | Jazz43 | Word | 0 | 02-14-2011 06:08 AM |