Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Rich text file handling difference 1

Status
Not open for further replies.

Capoerista

Programmer
Aug 13, 2002
44
0
0
GB
Hi All,

I am having problems with the following bit of code. The RTF handling is behaving differently on two PC's, both with Win 2000 professional. One has Office 2002 (works OK), the other has Office 2003. The code is in a VB6 application and is used to strip out the RTF 'control' codes to leave a plain text file. In particular the TS.ReadAll does not seem to be doing this on latter PC. Does anyone know if any changes have been made to RTF handling routines and is there something that I may need to install or coding changes to consider.

Thanks in advance

Adrian


Dim TS As Scripting.TextStream
Dim NewIn

Load frmEmail_2_OTC
Set TS = fso_OpenTextFile(INPUT_FILE, ForReading)
frmEmail_2_OTC.rtfTemp.TextRTF = TS.ReadAll
TS.Close

NewIn = fso.GetParentFolderName(INPUT_FILE) & "\OrigRTF_" & fso.GetFileName(INPUT_FILE)
If fso.FileExists(NewIn) Then
Kill NewIn
End If

Name INPUT_FILE As NewIn


'Name Run_File as
Set TS = fso_OpenTextFile(INPUT_FILE, ForWriting, True)


'Dim Res As String
Dim lins, ln, Lin

lins = Split(Trim(frmEmail_2_OTC.rtfTemp.Text), vbCrLf)

LineCount = UBound(lins)

For ln = UBound(lins) To 0 Step -1
If Trim(lins(ln)) <> "" Then
Exit For
Else
LineCount = LineCount - 1
End If
Next

For ln = 0 To LineCount
Lin = lins(ln)
Debug.Print Lin & vbCrLf
If Trim(left(Lin, 4)) = "____" Then
Lin = Space(Len(Lin))
End If

TS.Write Lin & vbCrLf
Next

TS.Close

Unload frmEmail_2_OTC
 
>The code is in a VB6 application and is used to strip out the RTF 'control' codes to leave a plain text file

Why don't you use a simple rich text box to do this.
Just load your rtf file in the RTB and save it as plain text like this.
__
[tt]
rtb.LoadFile "C:\Richtext.rtf", rtfRTF
rtb.SaveFile "C:\Poortext.txt", rtfText[/tt]
__

See also thread222-746987.

>TS.ReadAll does not seem to be doing this on latter PC.

You really don't need that TextStream object. You can load and save rtf files directly using the richtext box using LoadFile and SaveFile methods as I shown above. The rich text box handles all the file i/o itself.
 
Hypetia,

Sorry for delay in reply. Your suggestion works fine for me, but still does not work on our Outlook 2003 machine.

I managed to diagnose a case of DLL hell with Riched20.dll. Version 5.30 works OK and 5.50 does not (which is what Outlook 2003 uses). My inelegant workaround was to load the form as soon as the application starts up, this seems to get the right version into memory.

Ade
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top