Something like this,
Code:
Dim wrdApp As Object, wrdDoc As Object
On Error Resume Next
Set wrdApp = GetObject(Class:="Word.Application")
If wrdApp Is Nothing Then
Err.Clear
Set wrdApp = CreateObject(Class:="Word.Application")
If wrdApp Is Nothing Then
MsgBox "Microsoft Word could Not be found - Aborting"
Exit Sub
End If
End If
On Error GoTo 0
Application.ScreenUpdating = FALSE
Application.EnableEvents = FALSE
With wrdApp
.Application.ScreenUpdating = FALSE
Set wrdDoc = .Documents.Open("D: \08-02-21\test.docx")
.Visible = TRUE
.Activate
Dim HdrText As String
Dim BoldRange As Range
Dim HdrRange As Range
'Set Variable equal to Header Range
Set HdrRange = wrdDoc.Sections.Item(1).Headers(wdHeaderFooterPrimary).Range
‘Data To add To Header
HdrText = ThisWorkbook.Sheets("details").Cells(4,2).Value
'Add Text To Word Header
HdrRange.Text = HdrText
'Bold Only First Sentence in Header
Set BoldRange = HdrRange.Words(1) 'Get First Word
BoldRange.Expand (wdSentence) 'Expand To Entire Sentence
BoldRange.Font.Bold = TRUE 'Bold Entire Sentence
End With
But getting error at
wdHeaderFooterPrimary.
Also, I'm new to this kind of thing and I have not done word doc manipulation from excel.