Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to remove RTF code?

Status
Not open for further replies.

LFB

Programmer
Jul 2, 2001
38
0
0
AU
Hi All,

Running Office XP.

I haven't even attempted to tackle this hoping that somone out there can direct me to a macro that already does it all.

I have a scenario where I am bringing in data to Excel that contains RTF code.

If you are not familiar with this, RTF editors store text with code appended to the data so it can interpret bold, colours etc. So "Hello" would look something like {\rtf\ansi\ansicpg1252\defflang3081{\fontbl{\f0\fnil\fcharset0Arial;}} Hello \par}}

I need a macro that strips out all the code just leaving behind the text. I've got a bad feeling that no such code exists and I am going to have to pass the code through an RTF interpreter to spit out what I need.

Anyway, appreciate any help provided.

Cheers
 
How is the data separated?
You could write a Word macro which opens the RTF in Word, opens Excel (+ resp. Workbook), loops through the RTF text and assigns the values to the respective cells in Excel.
That way Word itself would strip the RTF code from the file.

Would that work out?
[santa2]

Andreas Galambos
EDP / Technical Support Specialist
(andreas.galambos@bowneglobal.de)
HP:
 
Can't you just pass it through a RichtextBox control - feed the RTF to the .TextRTF property, and then read the .Text property?
 
Hi All,

I went with Strongm's idea. Works a treat. Btw it is the .selRTF property not the .textRTF property that does the conversion.

Cheers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top