#1
|
|||
|
|||
Duplicating table set in word
I was hoping to get help from this. Please see comments in review section. Thanks. |
#2
|
||||
|
||||
Add the following code to an ordinary module:
Code:
Option Explicit Sub AddTable() Dim oTable As Table Dim oRng As Range Dim oCell As Range Dim i As Long ActiveDocument.Tables(ActiveDocument.Tables.Count).Range.Copy Set oRng = ActiveDocument.Tables(ActiveDocument.Tables.Count).Range oRng.End = oRng.End + 1 oRng.Collapse 0 oRng.Text = vbCr oRng.Collapse 0 oRng.Paste For i = 1 To ActiveDocument.Tables(ActiveDocument.Tables.Count).Range.Cells.Count ActiveDocument.Tables(ActiveDocument.Tables.Count).Range.Cells(i).Select Select Case i Case Is = 3, 4, 5, 8, 10, 12 Set oCell = ActiveDocument.Tables(ActiveDocument.Tables.Count).Range.Cells(i).Range oCell.End = oCell.End - 1 oCell.Text = "" Case Else End Select Next i ActiveDocument.Tables(ActiveDocument.Tables.Count).Range.Cells(3).Select End Sub Code:
Private Sub Document_ContentControlOnEnter(ByVal CCtrl As ContentControl) Application.ScreenUpdating = False Dim CCtrlRng As Range, TblRng As Range, i As Long, Prot As Variant, Pwd As String With ActiveDocument Set CCtrlRng = CCtrl.Range If CCtrlRng.Information(wdWithInTable) Then Set TblRng = CCtrlRng.Tables(1).Range i = .Range(0, TblRng.End).Tables.Count If (i < 3) Then Exit Sub If MsgBox("Add new SBAR set?", vbQuestion + vbYesNo) = vbYes Then Prot = .ProtectionType If Prot <> wdNoProtection Then Pwd = "" 'Insert password here .Unprotect Password:=Pwd End If AddTable .Protect Type:=Prot, Password:=Pwd End If End If End With Application.ScreenUpdating = True 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
|
|||
|
|||
Thanks heaps for this!
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
duplicating field values in a word document | howarths | Word | 5 | 11-05-2015 11:50 AM |
Large Word doc duplicating large sections when I print it. | Kea | Word | 3 | 05-30-2015 02:28 PM |
Find/Replace, Duplicating a word in a sentence to hundreds of sentences. | DDDD | Word | 0 | 10-08-2013 10:48 AM |
Outlook Duplicating Sent Items | eb123456 | Outlook | 0 | 02-15-2012 11:49 PM |
Issue with Word duplicating | cajun62234 | Word | 4 | 04-06-2011 07:12 PM |