Solved

RTF Codes in Access

Posted on 2008-09-29
10
531 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
  • 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
Technology Partners: 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 50

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 84
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 50

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 50

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

Industry Leaders: 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!

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…

685 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