Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 03-30-2021, 08:17 AM
andiekit andiekit is offline Adding new rows to a table Windows 10 Adding new rows to a table Office 2016
Advanced Beginner
Adding new rows to a table
 
Join Date: Sep 2019
Posts: 45
andiekit is on a distinguished road
Default Adding new rows to a table

Hi folks,



I've designed some forms in Word using tables. They use white boxes on a green background (see pic 1 and pic 2, the latter with guides).

I've added blank rows in between the white-box rows to give the forms some space.

But, when a customer goes to insert a new row, obviously, it doesn't add the blank row, just a new white-box row (see pic 3).

Is there any way around this?!

Thanks,

Andie
Attached Images
File Type: jpg form1.JPG (37.5 KB, 35 views)
File Type: jpg form2.JPG (47.3 KB, 35 views)
File Type: jpg form3.JPG (12.6 KB, 35 views)
Reply With Quote
  #2  
Old 03-30-2021, 09:08 PM
gmayor's Avatar
gmayor gmayor is offline Adding new rows to a table Windows 10 Adding new rows to a table Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,101
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

You could use a macro in the document template (or in the document if saved as macro enabled, but not the normal template or it will apply to all tables) to add two rows and format them as you tab out of the last cell.
Code:
Sub NextCell()
'Graham Mayor - https://www.gmayor.com - Last updated - 31 Mar 2021
Dim oTable As Table
Dim iCol As Integer, iRow As Integer
Dim lngLast As Long
    Set oTable = Selection.Tables(1)
    With oTable
        iCol = .Columns.Count
        iRow = .Rows.Count
        If Selection.InRange(.Cell(iRow, iCol).Range) Then
            lngLast = Val(.Cell(iRow, 1).Range.Text)
            .Rows(iRow).Range.Rows.Add
            .Rows(iRow).Range.Rows.Add
            .Rows(iRow + 1).Shading.BackgroundPatternColor = RGB(234, 244, 246)
            .Rows(iRow + 2).Shading.BackgroundPatternColor = wdColorAutomatic
            .Rows(iRow + 2).Cells(1).Range.Text = lngLast + 1
            .Rows(iRow + 2).Cells(2).Range.Select
            '.Rows(iRow + 2).Range.Style = "Form Body"
            Selection.Collapse 1
        Else
            Selection.Cells(1).Next.Range.Select
            Selection.Collapse 1
        End If
    End With
lbl_Exit:
    Set oTable = 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
  #3  
Old 04-07-2021, 03:47 PM
Guessed's Avatar
Guessed Guessed is offline Adding new rows to a table Windows 10 Adding new rows to a table Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Relying on double rows (even with macros) is going to be too confusing and problematic. I would recommend you just do a regular table with super thick borders (6pt). This gives you pretty much the same look without any complications to confuse the users.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #4  
Old 04-07-2021, 04:50 PM
macropod's Avatar
macropod macropod is offline Adding new rows to a table Windows 10 Adding new rows to a table Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Whilst I agree with Andrew regarding the desirability of avoiding double rows, I think a macro can also be made to replicate the structure fairly reliably where such avoidance isn't practical. For example:
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim RngSrc As Range, RngTgt As Range
With Selection
  If .Information(wdWithInTable) = False Then Exit Sub
  With .Tables(1)
    Set RngSrc = .Rows(.Rows.Count - 1).Range
    RngSrc.End = .Range.End
    Set RngTgt = .Range
    RngTgt.Collapse wdCollapseEnd
    RngTgt.FormattedText = RngSrc.FormattedText
    .Rows(.Rows.Count - 1).Range.Delete
    .Rows(.Rows.Count - 1).Cells(1).Range.Text = (.Rows.Count - 1) / 2
  End With
End With
Application.ScreenUpdating = True
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 04-15-2021, 08:09 AM
andiekit andiekit is offline Adding new rows to a table Windows 10 Adding new rows to a table Office 2016
Advanced Beginner
Adding new rows to a table
 
Join Date: Sep 2019
Posts: 45
andiekit is on a distinguished road
Default

Thanks so much, both of you. Great suggestions. My boss has a bit of an aversion to macros, so I'll give the other suggestion a go. Fingers crossed. Thanks again - really appreciate your help! Andie x
Reply With Quote
  #6  
Old 04-16-2021, 07:31 AM
andiekit andiekit is offline Adding new rows to a table Windows 10 Adding new rows to a table Office 2016
Advanced Beginner
Adding new rows to a table
 
Join Date: Sep 2019
Posts: 45
andiekit is on a distinguished road
Default

Hi folks, update time!

I've created the 6pt border, as suggested by Andrew, and it's worked great.

The only issue is the colour. I currently have it as the same green as the background behind it. I guess these greens are transparent and we now have "double green", so darker!

Is there a way to make the border colour colourless? I can't see an option for that.

Andie x

PS The header cells currently have no fill (what I'd like for the border if poss) and the body text cells have white fill.

PPS Can you make the border any thicker - eg 10pt - or is 6pt the max?
Attached Images
File Type: jpg Capture.JPG (62.5 KB, 21 views)
Reply With Quote
  #7  
Old 04-16-2021, 04:00 PM
macropod's Avatar
macropod macropod is offline Adding new rows to a table Windows 10 Adding new rows to a table Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Using the coding approach I suggested with the thicker borders (6pt is the max), you could use:
Code:
Sub Demo()
Application.ScreenUpdating = False
Dim RngSrc As Range, RngTgt As Range
With Selection
  If .Information(wdWithInTable) = False Then Exit Sub
  With .Tables(1)
    Set RngSrc = .Rows(.Rows.Count).Range
    Set RngTgt = .Range
    RngTgt.Collapse wdCollapseEnd
    RngTgt.FormattedText = RngSrc.FormattedText
    .Rows(.Rows.Count ).Range.Delete
    .Rows(.Rows.Count ).Cells(1).Range.Text = (.Rows.Count - 1) 
  End With
End With
Application.ScreenUpdating = True
End Sub
With this approach, whatever formatting, shading etc. is applied to your existing last row is replicated in the new one.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #8  
Old 04-19-2021, 04:25 AM
andiekit andiekit is offline Adding new rows to a table Windows 10 Adding new rows to a table Office 2016
Advanced Beginner
Adding new rows to a table
 
Join Date: Sep 2019
Posts: 45
andiekit is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
Using the coding approach I suggested with the thicker borders (6pt is the max), you could use:
...
With this approach, whatever formatting, shading etc. is applied to your existing last row is replicated in the new one.
Thank you, I would, but my boss is dead against tweaks to coding, macros and so on. We create Word documents for customers to be able to edit - so he wants to keep matters as simple as possible for them. Is there any other way to sort out the colour issue? x
Reply With Quote
  #9  
Old 04-20-2021, 03:38 PM
Guessed's Avatar
Guessed Guessed is offline Adding new rows to a table Windows 10 Adding new rows to a table Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

6pt is as thick as you can make the border. The only way to make it 'appear' thicker is to reduce the font size and zoom the page larger. If your text is 6pt then the borders will look a lot fatter than when the text is 12pt.

The border colour discrepancy is not because the line is partially transparent - Word can't do that. I think the issue you are seeing is that the background is in the header/footer layer and therefore is faded on screen. When you print it or show it in Print Preview you will see that the background and border is actually the same colour.

Making the border colourless would render this entire thread pointless. If it is important for you to not see the borders on screen or in print, why did you start this thread?
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #10  
Old 04-20-2021, 04:11 PM
macropod's Avatar
macropod macropod is offline Adding new rows to a table Windows 10 Adding new rows to a table Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by Guessed View Post
The border colour discrepancy is not because the line is partially transparent - Word can't do that. I think the issue you are seeing is that the background is in the header/footer layer and therefore is faded on screen.
If the page shading is the same as the table border shading, no difference will be apparent in Page Layout view. A difference would be seen, though, if the background shading has been applied to a shape located in the page header.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #11  
Old 04-21-2021, 04:42 AM
andiekit andiekit is offline Adding new rows to a table Windows 10 Adding new rows to a table Office 2016
Advanced Beginner
Adding new rows to a table
 
Join Date: Sep 2019
Posts: 45
andiekit is on a distinguished road
Default

Thanks Macro, yes, this was the case. No worries, though, I've removed the shape now and redesigned the forms - seems OK. Thanks for your help.
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA Adding Rows To Table With Content Control lord_kaiser Word VBA 2 08-01-2020 01:01 AM
Adding new rows to a table Add Rows to table that will include content controls of previous rows bobsagat Word VBA 20 01-27-2020 08:00 AM
Adding new rows to a table Adding Rows to a Table SuzeG Word VBA 8 01-02-2014 08:05 AM
Adding new rows to a table Grouping table rows to prevent individual rows from breaking across pages dennist77 Word 1 10-29-2013 11:39 PM
Adding new rows to a table adding rows to word table hklein Word VBA 4 07-18-2011 12:21 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:34 PM.


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