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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Strip out RTF to create Plain Text in Access 2003 1

Status
Not open for further replies.

AHJ1

Programmer
Oct 30, 2007
69
US
Hello,

I need to strip out the RTF code in a text box and place the resulting plain text in to another text box.

I have two approaches that might work. The first is to use a regular expression to take out the RTF. The second is to use Ole Automation to paste the text into Notepad, and then copy the plain text from notepad into another field.

Can anyone suggest a regular expression that will remove rich text code and/or show me the code to manipulate the notepad object?

I've started with this code:
Code:
'Copy contents of hidden textbox
    With Me!txtcusRTF
        .Visible = True
        .SetFocus
        .SelStart = 0
        .SelLength = Len(Me!txtcusRTF.Text)
    End With
        RunCommand acCmdCopy
    Me!txtcusRTF.Visible = False

'Here is where I want to strip out RTF or paste into Notepad, and then paste into a different text box.

    
    
Exit Sub
err_copystrip:
    ErrBox "stripping out RTF and pasting into table for searching in cmdCopyStrip_click"
End Sub
 
I'd use word for this.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Can you point to towards some code that will let me paste RTF into word and then convert it to text? When I copy and paste the code, it looks like this:
Code:
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Times New Roman;}}
{\colortbl ;\red0\green0\blue0;}
{\*\generator Riched20 5.50.99.2010;}\viewkind4\uc1\pard\cf1\b\f0\fs24 Joshua Wilson, Washoe County Assessor, and Tim Smith.\par
\par
}
 
AHJ1,
A couple of thoughts.

Does the Text box that displays the RTF have a [tt]Text[/tt] property? I know that the Microsoft Rich Textbox Control 6.0 does and can be used to do the conversion for you.

Copying from a control and pasting into Notepad is essentially using the Clipboard to do the conversion. You can eliminate Notepad by using the appropriate API calls. Take a look at [tt]EnumClipboardFormats[/tt] and [tt]GetClipboardData[/tt].

Hope this helps,
CMP

[small]For the best results do what I'm thinking, not what I'm saying.[/small]
(GMT-07:00) Mountain Time (US & Canada)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top