很简单,
下面的代码你看看就知道了,
strxxxxxxxxxxx就是你要写的内容。
___________________________________
var
FWord: Variant;
FDoc: Variant;
// FRange: Variant;
begin
Screen.Cursor := crHourGlass;
try
FWord := CreateOleObject('Word.Application');
FWord.Visible := True;//显示word,如果想在后台处理则不要这句
except
Screen.Cursor := crDefault;
ShowMessage('创建word对象失败!');
Exit;
end;
try
FDoc := FWord.Documents.Add;
FWord.Selection.TypeText(Text := strxxxxxxxxxxxxxxx);//你要写的文本
FWord.ChangeFileOpenDirectory('C:/Documents and Settings/Administrator/桌面/');//你要存入的目录
FWord.ActiveDocument.SaveAs(
FileName:='1111111111.doc',
FileFormat:=wdFormatDocument,
LockComments:=False,
Password:='',
AddToRecentFiles:=True,
WritePassword:='',
ReadOnlyRecommended:=False,
EmbedTrueTypeFonts:=False,
SaveNativePictureFormat:=False,
SaveFormsData:=False,
SaveAsAOCELetter:=False);
finally
Screen.Cursor := crDefault;
//如果是在后台处理的,还要关闭word,用Fword.quit就就可以了
end;