Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

RTF Codes in Access

Posted on 2008-09-29
10
Medium Priority
?
572 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
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 52

Accepted Solution

by:
Gustav Brock earned 2000 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 52

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 52

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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Windows Explorer lets you open cabinet (cab) files like any other folder. In VBA you can easily handle normal files and folders, but opening and indeed creating cabinet files takes a lot more - and that's you'll find here.
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Suggested Courses

916 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