This document provides code to open a .doc file in RichEdit when it normally cannot be done. The code uses OLE to open the .doc file in Word, save it as an .rtf file, load the .rtf file into RichEdit, and then delete the temporary .rtf file. The code sample demonstrates how to perform these actions when a button is clicked.
This document provides code to open a .doc file in RichEdit when it normally cannot be done. The code uses OLE to open the .doc file in Word, save it as an .rtf file, load the .rtf file into RichEdit, and then delete the temporary .rtf file. The code sample demonstrates how to perform these actions when a button is clicked.
Copyright:
Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online from Scribd
This document provides code to open a .doc file in RichEdit when it normally cannot be done. The code uses OLE to open the .doc file in Word, save it as an .rtf file, load the .rtf file into RichEdit, and then delete the temporary .rtf file. The code sample demonstrates how to perform these actions when a button is clicked.
Copyright:
Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online from Scribd
klo mas strike_set mo buka file .doc di Trichedit ya ga bisa, tapi bisa diakalin, yaitu file .
doc kita buka
pake OLE, trus disave ke format .rtf, baru kemudian .rtf-nya kita load ke Trichedit, lalu file .rtf-nya kita hapus, kodenya sbb:
procedure TForm1.Button1Click(Sender: TObject);
Var MSWord:Variant; fname : string; begin fname := extractfilepath(application.ExeName) + formatdatetime('yyMMddhhmmsszz',now) + '.rtf'; if OpenDialog1.Execute then begin MSWord := CreateOleObject('Word.Basic'); If not VarIsEmpty(MSWord) then begin MSWord.FileOpen(OpenDialog1.FileName); MSWord.FileSaveAs(Name := fname, Format:=6); try MSWord.AppClose; MSWord:=Unassigned; Richedit1.lines.loadfromfile(fname); finally deletefile(fname); end; end else showmessage('Error - ga bisa ngebuka MS Word!'); end; end;
NB : jangan lupa di bagian uses di tambahin comobj