Hi,
I would like to populate Content Controls in embeded Word document with data from Excel named ranges. Content control fields have same names (Title) as named ranges in Excel.

So far I managed with my code to populate only one specified Content Control field from Excel named range (see below) - otherwise code works fine.
Obviously I have many more Content Control´s fields in document and I would like code to go through ALL Content control fields, so that I dont have to do it manualy, one by one.

Thanks in advance for any sugestions.



Sub Populate_ContentControls_in_embeded_document()

Dim WordApp As Object
Dim WordDoc As Object
Dim CC As ContentControl

Set WordApp = GetObject(, "Word.Application")
    
With WordApp
Set WordDoc = .Documents("Dokument v " & ActiveWorkbook.Name) 'example of embeded document name: "Dokument v AAA_ZAKÁZKA.xlsm"
End With


'Go through all CC in embeded Word document and if there is some with title that is the same as excel named range - then populate CC with text from excel named range

For Each CC In WordDoc.ContentControls

    If CC.Title = ActiveWorkbook.Names("hello").Name Then
    CC.Range.Text = Range("hello").Text
    End If

Next


End Sub