Write/Paste RTF or HTML string into one cell??

G

Guest

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
 
T

Tim

Any code to show ?

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

Tim
 
D

David McRitchie

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/2005/02/23/html-in-cells-ii/
 
G

Guest

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
 

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