请教,我用以下代码把WORD文档转换成RTF(不考虑格式丢失)但转换后无论是用delphi的RICEIDE,还是用WINDOWS自带的写字板打开,显示的都是代码,请问是哪里出错了呢?谢谢uses Comobj;procedure TForm1.Button1Click(Sender: TObject);
var
WordApp: Variant;
begin
if OpenDialog1.Execute then
begin
WordApp := CreateOleObject('Word.Basic');
if not VarIsEmpty(WordApp) then
begin
WordApp.FileOpen(OpenDialog1.FileName);
WordApp.FileSaveAs(Name:= 'c:\temp_bb.rtf',Format:=6);
WordApp.AppClose;
WordApp:=Unassigned;
end
else ShowMessage('Could not start MS Word');
end;
end;
var
WordApp: Variant;
begin
if OpenDialog1.Execute then
begin
WordApp := CreateOleObject('Word.Basic');
if not VarIsEmpty(WordApp) then
begin
WordApp.FileOpen(OpenDialog1.FileName);
WordApp.FileSaveAs(Name:= 'c:\temp_bb.rtf',Format:=6);
WordApp.AppClose;
WordApp:=Unassigned;
end
else ShowMessage('Could not start MS Word');
end;
end;
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货