| Home | Previous Lesson: Programming RichTextEdit Control Next Lesson: Previewing & Printing Document From RTE Control |
There is no function to open a file in RTE control; However, you can insert either an ASCII file or rich-text file into the RTE control. If you are inserting a RTF document make sure the version of RTF is below or equal to 1.2. PowerBuilder supports only 1.2 RTF version. That means, you can not insert a document produced in MS-Word 6 or 7 or 97. The following code fragment taken from the example application demonstrates inserting a document.
String ls_Path, ls_File
If GetFileOpenName("Select File", ls_Path, &
ls_File, "rtf", "Rich Text (*.rtf), *.rtf") = 1 Then
is_FileName = ls_Path
// is_FileName is a instant string variable
rte_1.InsertDocument(is_FileName, True, &
FileTypeRichText!)
End If
In the above code we prompt the user for the RTF file name using GetFileOpenName() and open that document in the RTE control using InsertDocument(). The second argument to the InsertDocument() says whether you want to clear the content of RTE control before you insert the document or insert the document at the cursor location.
// is_FileName is a instance string variable
rte_1.SaveDocument(is_FileName, FileTypeRichText!)
Call SaveDocument() to save the document from the RTE control. In the above example we are saving the document to the same document. If you want to save the file as another file and want to get the file name from the user you can call GetFileSaveName().
| Home | Previous Lesson: Programming RichTextEdit Control Next Lesson: Previewing & Printing Document From RTE Control |