Solved

RTF Codes in Access

Posted on 2008-09-29
10
499 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
 
LVL 49

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
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
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 49

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 49

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

896 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now