Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 08-11-2017, 03:11 PM
macropod's Avatar
macropod macropod is offline Duplicating one or more table rows or an entire table with content controls Windows 7 64bit Duplicating one or more table rows or an entire table with content controls Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,521
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

The logic to add more than one row is essentially the same - you just need to extend the range being replicated to include those additional rows. ISTR posting code here some time ago to do something like that.

The code to replicate a table might be as simple as:
Code:
Private Sub Document_ContentControlOnExit(ByVal CCtrl As ContentControl, Cancel As Boolean)
  With CCtrl
    Call TableDuplicate(.Range.Tables(1).Range)
  End With
End Sub

Sub TableDuplicate(RngSrc As Range)
Dim RngTgt As Range
With ActiveDocument
  On Error Resume Next
  With RngSrc
    With .Tables(1).Range.Duplicate
      .Collapse wdCollapseEnd
      .InsertAfter vbCr & vbCr
      Set RngTgt = .Characters.Last
    End With
  End With
  RngTgt.FormattedText = RngSrc.FormattedText
End With
Set RngTgt = Nothing
End Sub
Of course, you'd need to integrate that with the other code that checks whether you're in the right table, whether the user actually wants to add a new table and, if so, clear any content controls in the new table.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to save docx to doc that checks compatibility and converts content controls to static content. staicumihai Word VBA 4 10-12-2016 08:23 PM
Duplicating one or more table rows or an entire table with content controls Duplicating table set in word emmanpelayo Word VBA 2 08-08-2016 08:41 PM
Duplicating one or more table rows or an entire table with content controls Is it possible to copy non-contiguous rows of a Table and paste them as a separate Table in Word? Joey Cheung Word Tables 1 08-12-2014 05:15 PM
Content Controls - Add Table Rows dgiromini Word VBA 1 04-11-2014 03:04 PM
Duplicating one or more table rows or an entire table with content controls Grouping table rows to prevent individual rows from breaking across pages dennist77 Word 1 10-29-2013 11:39 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:23 AM.


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