ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Save rich text somewhere in Excel? (https://www.excelbanter.com/excel-programming/454428-save-rich-text-somewhere-excel.html)

RG III

Save rich text somewhere in Excel?
 
Suppose I open a Word document full of rich text with colors and bold text, etcetera. Then I highlight everything with Ctrl-A and copy it into the clipboard with Ctrl-C.

Now, can I paste this rich text into a spreadsheet cell or somewhere in an Excel document and still retain all the rich text properties? If I have rich text stored somewhere in an Excel file, I'd like to create a macro that copies that rich text back into the clipboard. I know the command/functions for copying data into the clipboard using VBA. I just don't know how to store rich text in an Excel file.

Any ideas?

-Robert

Peter T[_8_]

Save rich text somewhere in Excel?
 
"RG III" wrote in message

Suppose I open a Word document full of rich text with colors and bold text,
etcetera. Then I highlight everything with Ctrl-A and copy it into the
clipboard with Ctrl-C.

Now, can I paste this rich text into a spreadsheet cell or somewhere in an
Excel document and still retain all the rich text properties? If I have
rich text stored somewhere in an Excel file, I'd like to create a macro that
copies that rich text back into the clipboard. I know the command/functions
for copying data into the clipboard using VBA. I just don't know how to
store rich text in an Excel file.

Any ideas?

-Robert

--------------------------------------------------------------

Try PasteSpecial HTML

Peter T



RG III

Save rich text somewhere in Excel?
 
On Saturday, September 14, 2019 at 2:01:33 AM UTC-7, Peter T wrote:

Try PasteSpecial HTML


This might work, except that it pastes each paragraph in a different row.

Now I just need to create a macro that reassembles the rich text into it's original single glob and copies it back into the clipboard.


RG III

Save rich text somewhere in Excel?
 

Try PasteSpecial HTML


Well, that does paste rich text into multiple Excel cells. Now I'm stuck trying to figure out how to copy the rich text from an Excel cell back into the clipboard in it's original rich text form.

Do you have any ideas?

-Robert


Peter T[_8_]

Save rich text somewhere in Excel?
 

"RG III" wrote in message


Try PasteSpecial HTML


Well, that does paste rich text into multiple Excel cells. Now I'm stuck
trying to figure out how to copy the rich text from an Excel cell back
into the clipboard in it's original rich text form.

Do you have any ideas?

-Robert


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
try pastespecial HTML again in Word. In other apps paste will get from the
clipboard in the app's default format.

Peter T




Peter T[_8_]

Save rich text somewhere in Excel?
 

"RG III" wrote in message

On Saturday, September 14, 2019 at 2:01:33 AM UTC-7, Peter T wrote:

Try PasteSpecial HTML


This might work, except that it pastes each paragraph in a different row.

Now I just need to create a macro that reassembles the rich text into it's
original single glob and copies it back into the clipboard.


Adjust the columnwidth to same as the Word doc's margins. Format with
word-wrap, if necessary 'AutoFit' row heights.

Peter T



RG III

Save rich text somewhere in Excel?
 
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

Peter T[_8_]

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




All times are GMT +1. The time now is 09:16 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com