Solved

RTF to TEXT in ActiveX dll.

Posted on 2003-10-23
5
419 Views
Last Modified: 2010-05-01
What is a good way to convert a RTF document into plain text inside of an ActiveX VB Dll?

Thanks
Greg
0
Comment
Question by:RowdyOne078
  • 2
  • 2
5 Comments
 

Expert Comment

by:JMCrenshaw
ID: 9609301
How complicatd is the RTF document. Does it make use of graphics, embedded images, tables etc.
0
 

Author Comment

by:RowdyOne078
ID: 9609311
it is a export from Crystal Reports 8.5 to RTF, so its wide open dependent on the reports.
0
 
LVL 9

Accepted Solution

by:
Dang123 earned 500 total points
ID: 9609463
You could add a form with the RichTextBox control on it and do something like this

Add a form with a Rich Text Box Control to your DLL project

Set module level variables to them in your class module

Private frmRT                   As frmRichText
Private WithEvents RichTextBox1 As RichTextBox


Initialize them in your class initialize
   Set frmRT = New frmRichText      ' Setup reference to
   Set RichTextBox1 = frmWS.RichTextBox1   ' richtextbox control

Get rid of them in your class terminate

   Set RichTextBox1 = Nothing
   Unload frmRS
   Set frmRS = Nothing


Work with it like this
    RichTextBox1.LoadFile strRtfFileNameAndPath, rtfRTF
    RichTextBox1.SaveFile strTxtFileNameAndPath, rtfText


From here you would have the text in a file that you could read back into a string.
0
 

Expert Comment

by:JMCrenshaw
ID: 9609501
You could use the RichText control, however it doesn't support a lot of the advanced or newer RTF commands and if the Crystal ouput uses those commands such as table and collums they would be ignored but you would get the text from it.

To do that you would need to place the control on a form, the Open the RTF File and output the data from the input command to the control. Once in the control you can use the Text property of the control that will return just the text part of the RTF.

This is a crude and messy way but it doesn't require the purchase of a third part tool.

Another way would be to look at using Word as a DDE server or via API calls, but this would requre the user to have Word installed.

Why not use Crstyal to Export to text instead ?
0
 

Author Comment

by:RowdyOne078
ID: 9609636
Crystal 8.5 has problems with exporting to plain text.  It cuts off fields and data.

0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

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…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

813 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

17 Experts available now in Live!

Get 1:1 Help Now