I’ve seen this, but it doesn’t work for me; I don’t get where to change insertafter to typetext. What should I change in the following to make part of the text bold?
Sub CreateNewWordDoc()
Dim wrdDoc As Word.Document
Dim wrdApp As Word.Application
Set wrdApp = CreateObject("Word.Application")
Set wrdDoc = wrdApp.Documents.Add
With wrdDoc
.Content.InsertAfter "not bold "
.Content.Font.Bold = True
.Content.InsertAfter "should be bold"
.Content.Font.Bold = False
.Content.InsertAfter " again not bold, followed by newline"
.Content.InsertParagraphAfter
.Content.Font.Bold = True
.Content.InsertAfter "bold again"
.Content.Font.Bold = False
.Content.InsertAfter " and again not bold"
.Content.InsertParagraphAfter
.SaveAs ("testword.doc")
.Close
End With
wrdApp.Quit
Set wrdDoc = Nothing
Set wrdApp = Nothing
End Sub
When you write
.Content.Font.Bold = Trueand.Content.Font.Bold = False, you’re toggling the entireContentback and forth between bold and not bold. The last statement of this sort is.Content.Font.Bold = False, so of course nothing ends up being bold.Here’s a way to do what you want. It’s really badly and quickly written but it should put you on the right track.