PDA

Click to See Complete Forum and Search --> : RTF file(s)


badgers
Jan 14th, 2000, 03:21 AM
I would like to say thank you to everyone who responded to my recent posts. I have found what the problem was. It appears that the file was corrupt. It would look correct in Word but I cut and pasted the text into a new word doc and now it works like a champ.

My question for today is this. I want to add 15 small RTF files to a richtextbox. basically concatination one after another. When I use the loadfile method I loose the files loaded before it. How does one add several files together to make a complete document?
Thank you for your time and have a good day

------------------
I am so skeptacle, I can hardly believe it!

netSurfer
Jan 14th, 2000, 03:35 AM
would it work to dump the files into a variable and concatenate them and then load that into the textbox?

Aaron Young
Jan 14th, 2000, 03:38 AM
Just open the File(s) you want to append Manually and Add the RTF Data to the End of the RTF Text, ie.

Private Sub Command1_Click()
AppendRTF RichTextBox1, "C:\Files\test.rtf"
End Sub

Private Sub AppendRTF(ByRef oRTFBox As RichTextBox, ByVal sFile As String)
Dim iFile As Integer
Dim sChunk As String
Dim lChunk As Long
Dim lLOF As Long
Dim sFileData As String

On Error GoTo RTFAppendError
iFile = FreeFile
Open sFile For Binary Access Read As iFile
lLOF = LOF(iFile)
lChunk = 64000
While Loc(iFile) < lLOF
If lChunk + Loc(iFile) > lLOF Then lChunk = lLOF - Loc(iFile)
sChunk = Space$(lChunk)
Get #iFile, , sChunk
sFileData = sFileData & sChunk
Wend
oRTFBox.SelStart = Len(oRTFBox)
oRTFBox.SelRTF = sFileData
RTFAppendError:
Close iFile
If Err Then MsgBox "Error: " & vbCrLf & Err.Description, vbCritical + vbOKOnly, "Error"
End Sub


------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
ajyoung@pressenter.com

badgers
Jan 14th, 2000, 03:55 AM
you da man!! :D