maintaining the formatting of a string

L

Larry

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?
 
J

Jay Freedman

Larry said:
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.
 
D

Doug Robbins

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
 

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