I used to know this but forget--If a text selection has character
formatting such as underlining, and I'm turning the selection into a
string and then inserting that string elsewhere, how do I maintain the
formatting of the string?

Re: maintaining the formatting of a string by Jay

Jay
Tue Aug 16 15:46:01 CDT 2005

Larry wrote:
> I used to know this but forget--If a text selection has character
> formatting such as underlining, and I'm turning the selection into a
> string and then inserting that string elsewhere, how do I maintain the
> formatting of the string?

If you turn it into a string, you *will* lose all formatting, because a
string has no place to store format information -- it's just a list of
character codes.

To preserve formatting, you can define a range for the destination, and
assign the source range to the .FormattedText property of the destination:

DestRg.FormattedText = Selection.Range

or, if you have a Range object SourceRg instead of the Selection,

DestRg.FormattedText = SourceRg

Look up the FormattedText property in the VBA help.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org



Re: maintaining the formatting of a string by Doug

Doug
Tue Aug 16 15:56:38 CDT 2005


ActiveDocument.Bookmarks("InsertHere").Range.FormattedText =
Selection.Range.FormattedText

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
"Larry" <larry328NOSPAM@att.net> wrote in message
news:%23zCGJCqoFHA.3380@TK2MSFTNGP12.phx.gbl...
>I used to know this but forget--If a text selection has character
> formatting such as underlining, and I'm turning the selection into a
> string and then inserting that string elsewhere, how do I maintain the
> formatting of the string?
>
>
>
>



Re: maintaining the formatting of a string by Larry

Larry
Tue Aug 16 17:10:02 CDT 2005

Thank you, Doug and Jay! Just what I needed.

Larry



Doug Robbins wrote:
> ActiveDocument.Bookmarks("InsertHere").Range.FormattedText =
> Selection.Range.FormattedText
>
>
> Doug Robbins - Word MVP
> "Larry" <larry328NOSPAM@att.net> wrote in message
> news:%23zCGJCqoFHA.3380@TK2MSFTNGP12.phx.gbl...
> > I used to know this but forget--If a text selection has character
> > formatting such as underlining, and I'm turning the selection into a
> > string and then inserting that string elsewhere, how do I maintain
> > the formatting of the string?