Hello Robbins
Thx for your answer. So if it is not possible to access it via its
title directly I coded a class module which can be simple used as
follows
1. Create a new class module with the name
2. copy paste the class module code
3. create a module with a test method and inserts the example
4. run your macro
.....cheers ....
-------------------------------------------------------------------------------
CLASS MODULE:
Option Explicit
Private dictContentControls
Private Sub Class_Initialize()
Dim i As Integer
Dim c As Collection
Set dictContentControls = CreateObject("Scripting.Dictionary")
For i = 1 To ActiveDocument.ContentControls.Count
If Not
dictContentControls.Exists(ActiveDocument.ContentControls.Item(i).title)
Then
Set c = New Collection
dictContentControls.Add
ActiveDocument.ContentControls.Item(i).title, c
Else
Set c =
getControls(ActiveDocument.ContentControls.Item(i).title)
End If
c.Add ActiveDocument.ContentControls.Item(i)
Next
End Sub
Public Function getControl(title) As ContentControl
Dim c As Collection
Set c = dictContentControls.Item(title)
Set getControl = c.Item(1)
End Function
Public Function getControls(Optional title) As Collection
If Not IsMissing(title) Then
Set getControls = dictContentControls.Item(title)
Else
Set getControls = getAllControls()
End If
End Function
Public Function getAllControls() As Collection
Dim c
Dim ctrl As ContentControl
Set getAllControls = New Collection
For Each c In dictContentControls.Items()
For Each ctrl In c
getAllControls.Add ctrl
Next
Next
End Function
--------------------------------------------------------------------------------------------
EXAMPLE MACRO
Private Sub Document_Open()
Dim cm As ContentControlsManager
Set cm = New ContentControlsManager
Dim c As Collection
Dim ctrl As ContentControl
Set ctrl = cm.getControl("MyDropdown")
ctrl.DropdownListEntries.Clear
ctrl.DropdownListEntries.Add "Red", 1
ctrl.DropdownListEntries.Add "Blue", 2
'get All Controls
Set c = cm.getControls()
For each ctrl in c
MsgBox ctrl.title
Next
End Sub