Thanks for this clarification Macropod, you are of course right.
I eventualy got and idea for code bellow which works fine, however I am unable to update Content Controls in Header or Footer.
Sub Populate_ContentControls_in_embeded_document()
Dim WordApp As Object
Dim WordDoc As Object
Dim CC As ContentControl
Dim CCName As String
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
CCName = CC.Title
If CC.Title = ActiveWorkbook.Names(CCName).Name Then
CC.Range.Text = Range(CCName).Text
End If
Next
End Sub
I tried this for header but it doesnt work:
For Each CC In WordDoc.Sections(1).headers(wdHeaderFooterPrimary).Range.ContentControls
CCName = CC.Title
If CC.Title = ActiveWorkbook.Names(CCName).Name Then
CC.Range.Text = Range(CCName).Text
End If
Next
Thanks again for any replies.