Results 1 to 6 of 6
  1. #1
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Save from RTF to TXT (VB6)

    Using a RichText Control, I can load a text file to view it's contents.
    If I edit the text file and save using:

    <pre>Me.RichTextBox1.SaveFile....Path......</pre>


    It obviously saves as a RTF file.
    This then creates a header: {rtf1ansideff0{fonttbl{f0fnilfcharset0 MS Sans Serif;}} and
    /Par at the start of each line.

    I would rather save the file as the original text file.
    Is FileSystemObject the way to go ?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Save from RTF to TXT (VB6)

    The SaveFile method has a second argument FileType. It can be rtfRTF (=0), the default, or rtfText (=1) to save as plain text. So use

    <code>Me.RichTextBox1.SaveFile "...", rtfText</code>

  3. #3
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Save from RTF to TXT (VB6)

    Thanks Hans

    I missed that argument.

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Save from RTF to TXT (VB6)

    Isn't this the control someone recently said has been disabled by a security update, or is that only when hosted in VBA?

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Save from RTF to TXT (VB6)

    A quick search shows that Problems occur when you use the Rich TextBox Control 6.0 in Office XP and in Office 2003. There are no security problems when using this control in a VB6 application.

  6. #6
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Save from RTF to TXT (VB6)

    Thanks, Hans. Microsoft makes me feel like such a second-class citizen. <img src=/S/sad.gif border=0 alt=sad width=15 height=15>

Posting Permissions

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