...eine Word Datei als Rtf speichern?
Autor: Daniel
uses
ComObj;
function ConvertDoc2Rtf(var FileName: string) : Boolean;
var
oWord: OleVariant;
oDoc: OleVariant;
begin
Result := False;
try
oWord := GetActiveOleObject('Word.Application');
except
oWord := CreateOleObject('Word.Application');
end;
oWord.Documents.Open(FileName);
oDoc := oWord.ActiveDocument;
FileName := ChangeFileExt(FileName, '.rtf');
oDoc.SaveAs(FileName);
oWord.ActiveDocument.Close(wdDoNotSaveChanges, EmptyParam, EmptyParam);
oWord.Quit(EmptyParam, EmptyParam, EmptyParam);
oDoc := VarNull;
oWord := VarNull;
Result := True;
end;
procedure TForm1.Button1Click(Sender: TObject);
const
FileName = 'c:\Document.doc';
begin
if ConvertDoc2Rtf(FileName) then
begin
ShowMessage('Word document has been converted to .rtf');
RichEdit1.Lines.LoadFromFile(FileName);
end;
end;
printed from
www.swissdelphicenter.ch
developers knowledge base