Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-18-2016, 01:29 AM
emmanpelayo emmanpelayo is offline Duplicating table set in word Windows 7 64bit Duplicating table set in word Office 2010 64bit
Novice
Duplicating table set in word
 
Join Date: Jul 2015
Posts: 22
emmanpelayo is on a distinguished road
Default Duplicating table set in word

I was hoping to get help from this. Please see comments in review section. Thanks.
Attached Files
File Type: docm DRAFT Mercy Report.docm (121.7 KB, 12 views)
Reply With Quote
  #2  
Old 07-18-2016, 04:53 AM
gmayor's Avatar
gmayor gmayor is offline Duplicating table set in word Windows 10 Duplicating table set in word Office 2016
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

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
Then modify your existing macro to call it
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
Reply With Quote
  #3  
Old 08-08-2016, 08:41 PM
emmanpelayo emmanpelayo is offline Duplicating table set in word Windows 7 64bit Duplicating table set in word Office 2010 64bit
Novice
Duplicating table set in word
 
Join Date: Jul 2015
Posts: 22
emmanpelayo is on a distinguished road
Default

Thanks heaps for this!
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Duplicating table set in word duplicating field values in a word document howarths Word 5 11-05-2015 11:50 AM
Duplicating table set in word 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
Duplicating table set in word Issue with Word duplicating cajun62234 Word 4 04-06-2011 07:12 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:51 AM.


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