Solved

RTF Codes in Access

Posted on 2008-09-29
10
544 Views
Last Modified: 2013-11-28
Experts,

Does anyone know of a utility that can sweep through an Access database and remove unwanted RTF codes?
0
Comment
Question by:NigelRocks
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
  • +1
10 Comments
 
LVL 75
ID: 22602576
Codes ... for example ?

mx
0
 
LVL 1

Author Comment

by:NigelRocks
ID: 22602594
RTF codes.  

{\rtf1\ansi\deff0{\fonttbl{\f0\fnil\fcharset0 MS Sans Serif;}}


I don't think that's the main issue,however.  I just need a utility that would get rid of what I tell it to.
0
 
LVL 75
ID: 22602608
This is the best Find and Replace tool available -- I've been using it daily for 15 years.  You can search fields in tables and replace the data.

http://www.rickworld.com/products.html#Find%20and%20Replace%209.0

mx
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 51

Accepted Solution

by:
Gustav Brock earned 500 total points
ID: 22603162
Yes, use the RTF control as shown below.
You can use the function in a query passing it the field in question.
If the field can be Null, you may use the second function.

/gustav
Public Function ConvRTFtoText( _
  ByVal strRTF As String, _
  Optional booSingleRun As Boolean) _
  As String
 
' Converts RTF formatted string to plain text using RTF ActiveX control.
' When finished, Rich Text object is removed if booSingleRun is True.
'
' 2001-05-27. Cactus Data ApS, CPH.
  
  Static objRTF As Object
  Static booErr As Boolean
  Dim strText   As String
  
  On Error GoTo Err_ConvRTFtoText
  
  If objRTF Is Nothing Then
    Set objRTF = CreateObject("RICHTEXT.RichtextCtrl")
  End If
  
  With objRTF
    .TextRTF = strRTF
    strText = .Text
  End With
  
  If booSingleRun = True Then
    Set objRTF = Nothing
  End If
  
  ConvRTFtoText = strText
  
Exit_ConvRTFtoText:
  Exit Function
 
Err_ConvRTFtoText:
  If booErr = False Then
    MsgBox "Error " & Err.Number & ". " & Err.Description & "!", _
           vbExclamation + vbOKOnly, _
           "Rich Text converter"
    ' Only show error message once per session.
    booErr = True
  End If
  Resume Exit_ConvRTFtoText
  
End Function
 
Public Function ConvVarRTFtoText( _
  ByVal varRTF As Variant, _
  Optional booSingleRun As Boolean) _
  As String
 
' Converts, if possible, RTF formatted variant to plain text using
' RTF ActiveX control.
' Null as varRTF returns zero length string.
' When finished, Rich Text object is removed if booSingleRun is True.
 
  Dim strRTF  As String
  Dim strTmp  As String
  
  On Error GoTo Err_ConvVarRTFtoText
  
  If Not IsNull(varRTF) Then
    strTmp = CStr(varRTF)
    strRTF = ConvRTFtoText(strTmp, booSingleRun)
  End If
 
  ConvVarRTFtoText = strRTF
 
Exit_ConvVarRTFtoText:
  Exit Function
 
Err_ConvVarRTFtoText:
  Resume Exit_ConvVarRTFtoText
 
End Function

Open in new window

0
 
LVL 85
ID: 22603627
I'm with gustav on this one ... I had to do something similar once, and the only way I could get the text out was with the methods he describes. I'm sure you could use a F&R utility (or just use Replace in VBA) but to try and figure out which was the text and I wanted and what were formatting commands was just insane ...
0
 
LVL 1

Author Comment

by:NigelRocks
ID: 22694887
I'm suddenly getting an error on the first statement in this block:

  With objRTF
    .TextRTF = strRTF
    strText = .Text
  End With

When it gets to this line

.TextRTF = strRTF

it gives me a 387 error saying that the "property cannot be set".  Keep in mind, this has worked before.

Ideas?
0
 
LVL 51

Expert Comment

by:Gustav Brock
ID: 22695043
Sounds like the object hasn't been created properly.

Check that it has not been blocked:

http://mail.localplanet.co.uk/Blogs/stuart/archive/2005/02/19/AccessActiveX.aspx

What it tells is to reset the Compatibility Flag for this entry to 0:

Rich Text Control
HKLM\SOFTWARE\Microsoft\Internet Explorer\ActiveX Compatibility\
{3B7C8860-D78F-101B-B9B5-04021C009402}

/gustav
0
 
LVL 1

Author Comment

by:NigelRocks
ID: 22696382
I can't find that GUID anywhere but under VB6.  It's not under \ActiveX Compatbility.  I re-registered it to make sure.
0
 
LVL 1

Author Comment

by:NigelRocks
ID: 22696406
Correction -- I found it other places, but nothing involving any "compatibility flag".
0
 
LVL 51

Expert Comment

by:Gustav Brock
ID: 22696785
I have no further ideas but have a look here for some hints:

http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_20642290.html

http://support.microsoft.com/kb/212733

You could also try to add the control permanently (menu Tool/References) if that should make a difference.

/gustav
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Suggested Courses
Course of the Month9 days, 5 hours left to enroll

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question