Insert bold text after range

O

O.B.1

Hi, I have so far the following code, being executed in a
for/next-loop:

Set oRange = objWordDoc.Range
oRange.InsertAfter "some text"
oRange.InsertAfter vbcrlf
oRange.InsertAfter vbtab & "again text" & vbcrlf

my question:
How can I set "some text" to appear in bold in the
document? (I'm using VB6 to create word documents)

Many thanks,
O.B.1.
 
D

Dave Lett

Hi,

You can modify your range object like the following:

With oRange
.InsertAfter "some text"
.Font.Bold = True
.InsertAfter vbCrLf
.InsertAfter vbTab & "again text" & vbCrLf
End With

HTH, Dave
 
G

Guest

I've tried this, but this approach puts the whole text in
bold, which in the purpose. Only the appended text should
appear in bold. Thx anyway!
 
J

Jonathan West

Hi O.B.1

Modify Dave's code as follows. I've added an extra line near the start

With oRange
.Collapse Direction:=0
.InsertAfter "some text"
.Font.Bold = True
.InsertAfter vbCrLf
.InsertAfter vbTab & "again text" & vbCrLf
End With
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top