Results 1 to 4 of 4

Thread: RTF file(s)

  1. #1

    Thread Starter
    Hyperactive Member badgers's Avatar
    Join Date
    Sep 1999
    Location
    Madison, WI USA
    Posts
    444

    Post

    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!

  2. #2
    Hyperactive Member
    Join Date
    Jun 1999
    Location
    Calgary Alberta
    Posts
    359

    Post

    would it work to dump the files into a variable and concatenate them and then load that into the textbox?

  3. #3
    Guru Aaron Young's Avatar
    Join Date
    Jun 1999
    Location
    Red Wing, MN, USA
    Posts
    2,177

    Post

    Just open the File(s) you want to append Manually and Add the RTF Data to the End of the RTF Text, ie.
    Code:
    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
    [email protected]
    [email protected]


  4. #4

    Thread Starter
    Hyperactive Member badgers's Avatar
    Join Date
    Sep 1999
    Location
    Madison, WI USA
    Posts
    444

    Post

    you da man!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width