艾,粘贴下吧
{Sub rtf()
'
' rtf Macro
' 宏在 2007-11-1 由 User 录制
'
ChangeFileOpenDirectory _
"C:/Program Files/Borland/Delphi6/Projects/wordToXml/"
ActiveDocument.SaveAs FileName:="abc.rtf", FileFormat:=wdFormatRTF, _
LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword _
:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
False
End Sub
}
procedure TForm1.Button1Click(Sender: TObject);
var
xlsApp: Variant;
sExcelFile: string;
begin
xlsApp := CreateOleObject('word.Application');
sExcelFile:= 'C:/Program Files/Borland/Delphi6/Projects/wordToXml/abc.doc';
try
xlsApp.Documents.Open(sExcelFile);
xlsApp.ActiveDocument.SaveAs('C:/Program Files/Borland/Delphi/Projects/wordToXml/abc.rtf',6);
finally
xlsApp.Quit;
xlsApp := null;
end;
end;