![]() |
#1
|
|||
|
|||
![]() Hello, I am trying to code a macro which could check whether a document has all needed named content controls and add missing if necessary. Let's say, the document should contain 3 CCs named "A", "B" and "C". If it contains only "A", the macro should add "B" and "C". My code is below. It adds all CCs if some of the 3 named CC are missing, but do not differentiate which one should be added. How to add check for missing CCs? Code:
Sub AddMissingCCs() Dim CCnames Dim i As Long Dim j As Long Dim CCcount As Long Dim CCtrl As ContentControl CCnames = Array("A", "B", "C") For i = 0 To UBound(CCnames) For Each CCtrl In ActiveDocument.ContentControls If (UBound(Filter(CCnames, CCtrl.Title)) = -1) Then Selection.EndKey Unit:=wdStory ActiveDocument.Range.InsertAfter vbCr Selection.Range.ContentControls.Add (wdContentControlPlain) Selection.ParentContentControl.Title = CCnames(i) End If Next Next End Sub |
Tags |
content controls |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
ajanson | Word | 3 | 08-15-2016 04:49 PM |
Have Text Entered in Content Control / PreDefined Field Populate Field in Footer | bzowk | Word | 1 | 04-14-2016 11:50 AM |
Check Box Content Control when checked users are presented with an option | cryder | Word | 0 | 01-07-2016 05:11 AM |
![]() |
canadansk | Word VBA | 5 | 04-01-2015 08:21 AM |
![]() |
ksigcajun | Word VBA | 4 | 10-13-2014 05:37 AM |