Link to home
Start Free TrialLog in
Avatar of gseales12
gseales12

asked on

Remove RTF codes on MS Access plain text memo field

I have a table with a plain text memo field that has text with RTF codes.  I want to remove all the RTF codes and be left with just the text.  Thanks for any help.
Avatar of Dale Fye
Dale Fye
Flag of United States of America image

Try the PlainText() function.
It may also be a bit more complicated depending on the exact text stored.

If this is true RTF text, ex:
{\rtf1\ansi\ansicpg1252\uc1\deff0\stshfdbch0\stshfloch0\stshfhich0\stshfbi0\deflang1033\deflangfe1033{\fonttbl{\f0\froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\f1\fswiss\fcharset0\fprq2{\*\panose 020b0604020202020204}Arial;}

...Then it may not a simple matter to strip out all of the rtf 'tags' and just be left with the readable text.
This would be easy if the readable text was "delimited", for example:
   #This is Readable text#


The only way I can see this being done is if you:
Copy this text to a file, and name it with an .rtf extension
Open the file in MS Word
Save the file as a text file
Import the new text file to Access.

Definitely not a simple task, .... so lets see what other experts may post...

Perhaps a better approach is to look backwards on this, and you can explain a bit more about this system  and why the data is stored as rtf "text"


JeffCoachman
ASKER CERTIFIED SOLUTION
Avatar of Gustav Brock
Gustav Brock
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of gseales12
gseales12

ASKER

Don't know why other than they wanted to allow for the text to have formatting.  These are notes from accounting package PFW by Sage(Platinum for Windows).  They stored the Universal notes for customer accounts in MS Access databases as plain text memo field.  I have installed an activeX control called RTF2 in the past to use these notes in my own MS Access apps.  We are now using Sage 100(previously MAS 90) running on MS SQL and I want to transfer these notes from MS Access to Sage 100, but do not want the RTF formatting.  Below is an example of one of the notes.  I did notice a pattern that many of the notes have "fs20"  before the actual text begins so I could try and do something like that but thought maybe someone else has tackled this kind of thing before.

{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 MS Sans Serif;}}
{\colortbl ;\red0\green0\blue0;}
\viewkind4\uc1\pard\cf1\f0\fs20 6/26/07 Number was busy each time tried, LM at home number, but customer never called back to confirm address for returned catalog; confirm if reorder\cf0\fs17
\par }

I will give your code a try cactus.
Thanks cactus, that did it.  Knew there had to be a way to use the RTF control.
You are welcome!

/gustav
gustav,

Good catch as always, ...on using the rtf control...
;-)

Jeff
Thanks!
Did you notice the date of that function? Around the birth of WinXP. I'm feeling old.

/gustav
Now that you pointed it out.  Don't remind me, now I feel even older because I remember using/trying Windows 3.1.  Ended up sticking with DOS and Unix.
Oh, I still have the Win 3.11 box - soon it will be 20 years old.
Could be fun to fire it up some day ...

/gustav
Now I feel better...I never even owned a copy.  I don't know about firing it up, as it will be more like a glacier.  :-)
I think you just ran setup.exe /a from a network drive (after booting to DOS, of course, and having installed DOS network drivers). Today, it would probably take no more than a minute or two.

/gustav
Hi, I'm trying to do the same thing and used Gustav's solution code above but get an error when the function is run:  Rich Text Converter  Error 429. ActiveX component can't create object!  It jumps to error at the CreateObject statement.  I've tried RICHTEXT.RichtextCtrl and RICHTEXT.RichtextCtrl.1
Same issue on machine with Access 2003 and another with Access 2010.
Thanks for any help...
I just wrote an article on this.  I will let you know when it is published and include a link to the article.