Bold text and Highlight text

A

Amy Cox

I'm working in Word XP and I have not been able to
determine how to Bold text that is within a string
variable. Also, how do I Highlight text that is within a
string variable.

Thanks. Amy
 
A

Andrew Savikas

Hi Amy

A string variable only holds the string itself, not any formatting. You can apply bolding to a Font or Range object, but not to a string.

For example, if you had the word "Foobar" in 12-point bold, and selected it, your selection could be represented as an object that had the following properties

Selection.Font.Size = 1
Selection.Font.Bold = Tru
Selection.Text = "Foobar

To make this selection italic, you don't make the text italic, you make the selection italic

Selection.Font.Italic = True

That doesn't change anything about the value of the Selection.Text property

I know this is can be confusing (and perhaps I'm not helping here), but if you provide more specifics about what you're trying to accopmplish, you may get a more specific and more helpful response

Q. How do I insert a string at the end of the first paragraph, and italicize it

A. Dim myString as Strin
myString = "Foo the bar
Dim rng As Rang
Set rng = ActiveDocument.Paragraphs.First.Rang
rng.Start = rng.End -
rng.Collapse wdCollapseStar
rng.InsertAfter st
rng.Font.Bold = Tru
Set rng = Nothin

HTH
Andrew Savika

----- Amy Cox wrote: ----

I'm working in Word XP and I have not been able to
determine how to Bold text that is within a string
variable. Also, how do I Highlight text that is within a
string variable

Thanks. Am
 

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