ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Write/Paste RTF or HTML string into one cell?? (https://www.excelbanter.com/excel-programming/392349-write-paste-rtf-html-string-into-one-cell.html)

Bourgui

Write/Paste RTF or HTML string into one cell??
 
Hi experts,

I have this problem that's stalled me for a few days now: I want to pass
formatted text to an Excel cell. It sounds simple enough, but apparently it
isn't.

The original text can be in RTF or HTML format. The closest I have come is
copying my data as HTML on the clipboard then pasting as HTML, however for
each line break the content gets sent to the next cell. I want to have it all
in one cell.

Anybody has any idea? I don't need to use the clipboard, that's just
something that I thought might work...

Cheers!

Bourgui

Tim

Write/Paste RTF or HTML string into one cell??
 
Any code to show ?

If you paste into the cell *while in edit mode* it should all go into the
same cell.

Tim


"Bourgui" wrote in message
...
Hi experts,

I have this problem that's stalled me for a few days now: I want to pass
formatted text to an Excel cell. It sounds simple enough, but apparently
it
isn't.

The original text can be in RTF or HTML format. The closest I have come is
copying my data as HTML on the clipboard then pasting as HTML, however for
each line break the content gets sent to the next cell. I want to have it
all
in one cell.

Anybody has any idea? I don't need to use the clipboard, that's just
something that I thought might work...

Cheers!

Bourgui




David McRitchie

Write/Paste RTF or HTML string into one cell??
 
You cannot paste a table into a cell like you can in MS Word.
Nor can you paste text from HTML that has different fonts
attributes for different parts of the line (color, bold, italics) into Excel
like you can in MS Word.

In fact changing the font within parts of a cell can be rather
laborious in Excel. You have to do your selection from
the address bar not from the cell, and you can never have
multiple fonts/colors within a cell at same time unless it is
text (not a formula). I can't find my page but here is Dick's
http://www.dicks-blog.com/archives/2...l-in-cells-ii/

--
HTH,
David McRitchie, Microsoft MVP - Excel
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Tim" <tim j williams at gmail dot com wrote in message ...
Any code to show ?

If you paste into the cell *while in edit mode* it should all go into the
same cell.

Tim


"Bourgui" wrote in message
...
Hi experts,

I have this problem that's stalled me for a few days now: I want to pass
formatted text to an Excel cell. It sounds simple enough, but apparently
it
isn't.

The original text can be in RTF or HTML format. The closest I have come is
copying my data as HTML on the clipboard then pasting as HTML, however for
each line break the content gets sent to the next cell. I want to have it
all
in one cell.

Anybody has any idea? I don't need to use the clipboard, that's just
something that I thought might work...

Cheers!

Bourgui






Bourgui

Write/Paste RTF or HTML string into one cell??
 
THanks for the reply guys.

@Tim: not really any code to show yet. The formatted text comes from another
application, I really just need this function in Excel to somehow insert the
whole formatted text in one cell.

@Richie: The data is really just a string, that I can export in any format I
want. I was thinking of RTF because it's pretty much standard for formatted
text. HTML came as a second thought when I realised that, for example, if you
copy some formatted text from Word onto the clipboard, HTML is the format (of
the data on the clipboard) that Excel pastes. THe problem is when the text I
try to paste contains line breaks, as each line will then be pasted in
different cells instead of one.

I'm not worried about formulas as it will only ever be text.
I have just thought about getting rid of '<br in the HTML string I'm
passing, while keeping a reference of their position, then inserting 'vbLf'
in the appropriate positions in the cell later on. I'll let you know if it
worked (in case anyone else is trying to do the same thing)

I will check 'Bill' 's blog, thanks

"David McRitchie" wrote:

You cannot paste a table into a cell like you can in MS Word.
Nor can you paste text from HTML that has different fonts
attributes for different parts of the line (color, bold, italics) into Excel
like you can in MS Word.

In fact changing the font within parts of a cell can be rather
laborious in Excel. You have to do your selection from
the address bar not from the cell, and you can never have
multiple fonts/colors within a cell at same time unless it is
text (not a formula). I can't find my page but here is Dick's
http://www.dicks-blog.com/archives/2...l-in-cells-ii/

--
HTH,
David McRitchie, Microsoft MVP - Excel
My Excel Pages: http://www.mvps.org/dmcritchie/excel/excel.htm
Search Page: http://www.mvps.org/dmcritchie/excel/search.htm

"Tim" <tim j williams at gmail dot com wrote in message ...
Any code to show ?

If you paste into the cell *while in edit mode* it should all go into the
same cell.

Tim


"Bourgui" wrote in message
...
Hi experts,

I have this problem that's stalled me for a few days now: I want to pass
formatted text to an Excel cell. It sounds simple enough, but apparently
it
isn't.

The original text can be in RTF or HTML format. The closest I have come is
copying my data as HTML on the clipboard then pasting as HTML, however for
each line break the content gets sent to the next cell. I want to have it
all
in one cell.

Anybody has any idea? I don't need to use the clipboard, that's just
something that I thought might work...

Cheers!

Bourgui








All times are GMT +1. The time now is 05:37 PM.

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