![]() |
#1
|
|||
|
|||
![]()
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 |
#2
|
||||
|
||||
![]()
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 |
#3
|
||||
|
||||
![]()
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 |
#4
|
||||
|
||||
![]()
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] |
![]() |
Thread Tools | |
Display Modes | |
|
![]() |
||||
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 |
![]() |
bobsagat | Word VBA | 20 | 01-27-2020 08:00 AM |
![]() |
SuzeG | Word VBA | 8 | 01-02-2014 08:05 AM |
![]() |
dennist77 | Word | 1 | 10-29-2013 11:39 PM |
![]() |
hklein | Word VBA | 4 | 07-18-2011 12:21 AM |