Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #9  
Old 08-14-2017, 10:31 PM
macropod's Avatar
macropod macropod is online now 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,519
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

Try:
Code:
Sub InsertRowWithContent()
Application.ScreenUpdating = False
Dim vProtectionType As Variant, strPassword As String
Dim oRng As Word.Range, c As Long, i As Long, j As Long, t As Long
With Selection
  If .Information(wdWithInTable) Then
    With ActiveDocument
      vProtectionType = .ProtectionType
      If vProtectionType <> wdNoProtection Then
        strPassword = "" 'Insert password here
        .Unprotect Password:=strPassword
      End If
    End With
    With .Tables(1)
      j = .Range.Cells.Count + 1
      .Rows.Add
      For c = .Range.Cells.Count To j Step -1
        Set oRng = .Cell(.Range.Cells(c).RowIndex - 1, .Range.Cells(c).ColumnIndex).Range
        oRng.End = oRng.End - 1
        With .Range.Cells(c).Range
          'create new row content.
          On Error Resume Next
          .FormattedText = oRng.FormattedText
          On Error GoTo 0
          If .ContentControls.Count > 0 Then .Shading.BackgroundPatternColorIndex = wdNoHighlight
          'Work with new row content.
          For i = 1 To .ContentControls.Count
            With .ContentControls(i)
              Select Case .Type
                Case wdContentControlCheckBox: .Checked = False
                Case wdContentControlRichText, wdContentControlText, wdContentControlDate: .Range.Text = ""
                Case wdContentControlDropdownList, wdContentControlComboBox
                  t = .Type
                  .Type = wdContentControlText
                  .Range.Text = ""
                  .Type = t
                Case wdContentControlPicture
                  If Not .ShowingPlaceholderText Then
                    If .Range.InlineShapes.Count > 0 Then .Range.InlineShapes(1).Delete
                  End If
              End Select
            End With
          Next i
        End With
      Next c
    End With
    If vProtectionType > wdNoProtection Then ActiveDocument.Protect Type:=vProtectionType, Password:=strPassword
  Else
    MsgBox "The cursor must be locate in a table row containing content controls.", _
      vbInformation, vbOKOnly, "INVALID SELECTION"
  End If
End With
Application.ScreenUpdating = False
End Sub
__________________
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 09:52 PM.


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