good day guys.!

I just want to know on how to save to a .rtf(rich text format) file the content of the rich text box created in vb6 with pictures & text. I also want to retrieve the content of the .rtf file being created and display it again in a rich text box in vb6. Would this be possible?

Thank you for giving time..

Gosd bless us all.

Dani AI

Generated

Short summary and practical follow-ups to the answers above (thanks to and ): the VB6 RichTextBox can persist formatted text and embedded graphics to an .rtf file, but you must actually embed the picture into the control (not just display it on the form) and save in RTF mode — otherwise images will be lost. The control is a wrapper around the Windows RichEdit API and does not implement every RTF feature Word supports, so results can vary by OS / RichEdit version. (developerfusion.com)

A reliable quick method in VB6 is: copy the image to the Clipboard and paste it into the RichTextBox (the control will insert the image as an OLE/RTF object). Example pattern (VB6) — copy a PictureBox.Picture (or any image) into the clipboard then send a WM_PASTE to the RichTextBox:

' declarations at top of module
Declare Function SendMessage Lib "user32" Alias "SendMessageA" _
    (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Const WM_PASTE = &H302

' example button click
Private Sub cmdInsert_Click()
    Clipboard.Clear
    Clipboard.SetData Picture1.Picture   ' put picture on clipboard
    SendMessage RichTextBox1.hwnd, WM_PASTE, 0, ByVal 0&
End Sub

After pasting, save the control in RTF format so the embedded picture is written into the .rtf payload. (vb-town.tripod.com)

Troubleshooting notes (most common causes when images disappear or show as a dot):

  • The file was saved/loaded as plain text instead of RTF — confirm you save/load as RTF. (developerfusion.com)
  • Different RichEdit versions/storage formats: images may be stored as \wmetafile8 (usual) or \pngblip; some hosts/controls (and different Windows versions) don’t render every image blip type. Inspect the .rtf in Notepad for a {\pict ...} block to confirm image data is present. If a pasted image shows as a dot in another app (for example when migrating to .NET), it’s usually a format/version issue. (stackoverflow.com)

If portability matters (sharing with other apps or moving to .NET), either convert embedded images to a widely-supported metafile format when inserting, store images alongside the RTF (and rehydrate on load), or use a modern/third‑party rich-text control that explicitly supports embedded images and current RTF features. Always test saved .rtf files in WordPad (a good compatibility check) before deploying. (help.grapecity.com)

Final note: — glad you solved it. If images still fail in your environment, add the exact OS, RichEdit version, and a small failing .rtf sample (open it in Notepad and copy the small \pict block) to help pinpoint whether the problem is insertion, saving, or the target control’s rendering.

Recommended Answers

All 3 Replies

Is there not a RTB.SaveAs or SaveFile or Save property? And if so, why have you not pressed F1 to read all about it? :)

Good Luck

Use RichTextBoxName.SaveFile(pathname) and RichTextBox.LoadFile pathname. The default file format is RTF.

thank you for the suggestion..Ive just solved this problem yesternight.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.