Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-10-2015, 05:41 AM
Lizsaskia Lizsaskia is offline Adding table row to text style Windows 7 64bit Adding table row to text style Office 2013
Novice
Adding table row to text style
 
Join Date: Mar 2015
Posts: 5
Lizsaskia is on a distinguished road
Default Adding table row to text style

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?
Reply With Quote
  #2  
Old 03-10-2015, 05:51 AM
gmayor's Avatar
gmayor gmayor is offline Adding table row to text style Windows 7 64bit Adding table row to text style Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,106
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 of
Default

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
Reply With Quote
  #3  
Old 03-10-2015, 07:22 AM
Lizsaskia Lizsaskia is offline Adding table row to text style Windows 7 64bit Adding table row to text style Office 2013
Novice
Adding table row to text style
 
Join Date: Mar 2015
Posts: 5
Lizsaskia is on a distinguished road
Default Examples Attached

Thanks - here are two documents showing the problem and the solution that I want to automate
Attached Files
File Type: docx Minutes Template Problem.docx (77.1 KB, 15 views)
File Type: docx Minutes Template Solution.docx (77.1 KB, 9 views)
Reply With Quote
  #4  
Old 03-10-2015, 08:24 AM
gmayor's Avatar
gmayor gmayor is offline Adding table row to text style Windows 7 64bit Adding table row to text style Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,106
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 of
Default

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
Reply With Quote
  #5  
Old 03-10-2015, 10:35 AM
Lizsaskia Lizsaskia is offline Adding table row to text style Windows 7 64bit Adding table row to text style Office 2013
Novice
Adding table row to text style
 
Join Date: Mar 2015
Posts: 5
Lizsaskia is on a distinguished road
Smile Almost!

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!
Attached Files
File Type: dotm Minutes Template Solution.dotm (96.9 KB, 11 views)
Reply With Quote
  #6  
Old 03-10-2015, 10:52 PM
gmayor's Avatar
gmayor gmayor is offline Adding table row to text style Windows 7 64bit Adding table row to text style Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,106
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 of
Default

OK no problem. Locate the two lines
Code:
oRow.Cells(3).Range.ListFormat.RemoveNumbers NumberType:=wdNumberParagraph
and immediately after each add
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
This will force the cell widths to match the first section.
__________________
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
  #7  
Old 03-11-2015, 04:23 AM
Lizsaskia Lizsaskia is offline Adding table row to text style Windows 7 64bit Adding table row to text style Office 2013
Novice
Adding table row to text style
 
Join Date: Mar 2015
Posts: 5
Lizsaskia is on a distinguished road
Smile Thank you!

Thank you Graham you are amazing!!
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding table row to text style how to apply table style WITHOUT setting it as a table? 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

Other Forums: Access Forums

All times are GMT -7. The time now is 10:43 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft