Are the commands or switches I can use to directly assign text to a string
within a macro with formatting? For instance, if I have:
strText = "This is my text."
can I format it, say, bold so when I write it to a document I get:
"This is my text."
Ed
Jay Freedman - 04 Apr 2006 16:53 GMT
No. A string is just a sequence of characters -- there's nowhere in it to
store any formatting. You must insert the string into the document and then
format it there. IMHO, the best way to do that is with a Range object. For
instance, say you want to insert and format the string after the current
selection:
Dim strText As String
Dim rg As Range
strText = "This is my text."
Set rg = Selection.Range
rg.Collapse wdCollapseEnd
rg.Text = strText
rg.Bold = True
Set rg = Nothing ' cleanup

Signature
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
> Are the commands or switches I can use to directly assign text to a
> string within a macro with formatting? For instance, if I have:
[quoted text clipped - 3 lines]
>
> Ed
Helmut Weber - 04 Apr 2006 17:03 GMT
Hi Ed,
IMHO, no.
A string is a sequence of bytes.
One could set up a two dimensional array for formatting,
which holds the formatting information for each character,
but I'd say, forget about it.
Would be a nive feature to have.
Not too difficult, but lots and lots of tedious coding.

Signature
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"