Solved

RTF Codes in Access

Posted on 2008-09-29
10
481 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

760 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

20 Experts available now in Live!

Get 1:1 Help Now