View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Peter T[_8_] Peter T[_8_] is offline
external usenet poster
 
Posts: 88
Default Save rich text somewhere in Excel?

"RG III" wrote in message
On Saturday, September 14, 2019 at 4:48:35 AM UTC-7, Peter T wrote:

Nothing to do. By default when you copy from in Excel it copies to the
clipboard in a variety of 'clipboard formats' in including rich text and
HTML. There are different options for copying graphics.

If pasting back into Word could use paste-special rich-text (n/a in
Excel)
but theme colours will get pasted as RGB's not necessarily the same. Also
the L/R margins will adjust to the cell width but easy enough to adjust.
But pastespecial HTML again in Word. In other apps paste will get from
the clipboard in the app's default format.


Sorry if I wasn't clear. But I was looking for VBA macro code that copied
the rich text from a cell back into the clipboard.

I think I found a solution though. If cell A1 contains pre-pasted rich
text consisting of colors, underlines, and bold text in cell A1, then the
following code should copy the rich text back into the clipboard:

Range("A1").Select ' Grab the rich text
Selection.Copy ' Now send it to the clipboard


That's simply a normal copy, like selecting A1 and Ctrl-C

FWIW for most operations with VBA there's no need no need to select or
activate anything, eg

Dim rng As Range
Set rng = Range("A1")
rng.Copy

Peter T