I have a MS Excel worksheet with custom script. Part of this script is supposed to edit information in a MS Word document.
The thing that needs to be edited is text stored in a table cell in the Word document. I managed to edit the text it self, but I need to set part of the text to bold.
How can I do this?
Here is an example. Say I need to enter "123456789" in the table cell(1,1) and set the first characters "12345" to bold. Like this:
From Excel. Here is what I tried:
Dim SavePath as string
SavePath = "... path ..."
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Open(SavePath)
objWord.Visible = True
objDoc.Tables(1).Cell(1, 1).Range.Text = "123456789"
'So far, so good. The next part (how to set part of text to bold) is what I can't figure out. This does not work:
With objDoc.Tables(1).Cell(1, 1).Range(Start:=0, End:=5)
.Content.Font.Bold = True
End With
I know I can set a whole single cell to bold with this:
objDoc.Tables(1).Cell(ThisRow, ThisCol).Range.Bold = True
But can I address specific characters within a cell?
Can anyone help me?