Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / ActiveX Controls / February 2005

Tip: Looking for answers? Try searching our database.

Getting plain text RTF2

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Peter-d - 08 Feb 2005 17:21 GMT
Hello everyone

I've been using Stephen Lebans caladar control for some time with great
satisfaction so I decided to try his RTF2 Activex control.

At first view it seems to work fine, but as part of my normal usage, I would
like to be able to programatically (not using a form) convert the RTF text to
plain text. For example, I'd like to simply produce a query to my data and
copy the result in excel for further manipulation, analysis and graphing. So
I'd like my query to show the plain text (formatting is not an issue in this
process but is in other part of my business needs).

So I tried to code a function that would define an RTF2 object, set the
RTFText property and attempt to return the plain text property. But that
didn't work.
e.g.
Function MakePlainTextfromRTF(ByVal sRTFString As String) As String
Dim RTF As New RTF2
   If sRTFString <> "" Then
       RTF.RTFtext = sRTFString
       MakePlainTextfromRTF = RTF.PlainText
   End If
End Function

Anybody have a better idea? Or hints as to where I went wrong? Or is that
even possible?

Thanks
Alex Dybenko - 08 Feb 2005 17:36 GMT
i would suggest to make a hidden form with rtf control and use control on
it.

Signature

Alex Dybenko (MVP)
http://Alex.Dybenko.com
http://www.PointLtd.com

> Hello everyone
>
[quoted text clipped - 28 lines]
>
> Thanks
Peter-d - 08 Feb 2005 18:37 GMT
Thanks for the suggestion.
However, I can't see how this would work with wanting to extract a few
hundred records. I would think that if I process each record one at a time
using the hidden form that the process would take too long.

Any other ideas?

> i would suggest to make a hidden form with rtf control and use control on
> it.
[quoted text clipped - 31 lines]
> >
> > Thanks
Alex Dybenko - 08 Feb 2005 19:06 GMT
You can also make a function which converts RTF to text, i once found few in
google to convert RTF to HTML, so you can easy modify it to plain text
version

Signature

Alex Dybenko (MVP)
http://Alex.Dybenko.com
http://www.PointLtd.com

> Thanks for the suggestion.
> However, I can't see how this would work with wanting to extract a few
[quoted text clipped - 43 lines]
>> >
>> > Thanks
Alex Dybenko - 09 Feb 2005 06:53 GMT
don't understand your concern, your function will look like:

   docmd.openform "formwithRTF",,,,,acHidden ' this you can do once
   If sRTFString <> "" Then
       forms("formwithRTF").RTF.TextRTF = sRTFString
       MakePlainTextfromRTF = forms("formwithRTF").RTF.Text
   End If

Signature

Alex Dybenko (MVP)
http://Alex.Dybenko.com
http://www.PointLtd.com

> Thanks for the suggestion.
> However, I can't see how this would work with wanting to extract a few
[quoted text clipped - 43 lines]
>> >
>> > Thanks
Peter-d - 09 Feb 2005 08:49 GMT
Ok, I see what you mean. I was imagining at first a form with bound control.
This makes more sense. But I think my other solution will suit me better. One
less form in my project . I already have too many.

Thanks again.

> don't understand your concern, your function will look like:
>
[quoted text clipped - 51 lines]
> >> >
> >> > Thanks
Peter-d - 08 Feb 2005 19:11 GMT
Well actually the following code works:

Function MakePlainTextfromRTF(ByVal sRTFString As String) As String
Dim RTF As New RichTextLib.RichTextBox
   If sRTFString <> "" Then
       RTF.TextRTF = sRTFString
       MakePlainTextfromRTF = RTF.Text
   End If
End Function

And I can create a query and use this function in a field like:
 "Select MakePlainTextfromRTF([RTFField]) as PlainText from tblMyTable;"
and it will return all records in plain text.

But it didn't work when using the RTF2 control. I'd like to not call yet
another reference if I don't have to, so if anyone has a solution, I'd
appreciate.

On a different subject, does anyone have an opinion of the effect of having
multiple reference in an Access application? I'd have 12 total if I was to
keep both RTF2 and Microsoft RichText.

> Hello everyone
>
[quoted text clipped - 24 lines]
>
> Thanks
Ron Weiner - 08 Feb 2005 21:51 GMT
Peter

You could use late binding.

Public Function MakePlainTextfromRTF(ByVal sRTFString As String) As String
   Dim RTF As Object
   Set RTF = CreateObject("RICHTEXT.RichtextCtrl")
   If sRTFString <> "" Then
       RTF.TextRTF = sRTFString
       MakePlainTextfromRTF = RTF.Text
   End If
End Function

You will need a error handler to handle the case (Error 429 Can't create
object) that the object can not be created.

Ron W
> Well actually the following code works:
>
[quoted text clipped - 46 lines]
> >
> > Thanks
Peter-d - 08 Feb 2005 22:37 GMT
Thanks...

I had tried that, but didn't name the class properly so was getting the
error you mentioned. Any idea under what circumstance I might get that error?
Maybe if the activex in not installed on the user's computer?

> Peter
>
[quoted text clipped - 70 lines]
> > >
> > > Thanks
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.