p; Count := num; Extend := wdExtend; FWord.Selection.MoveRight(Unit_, Count, Extend); except MoveRight(); end; end; //鼠标右移 procedure TMyWord.MoveRight(num: Integer = 1); var Unit_: olevariant; Count: olevariant; Extend: olevariant; begin try //connectword(); Unit_ := wdCell; Count := num; FWord.Selection.MoveRight(Unit_, Count, Extend); except MoveRight(); end; end; //写字 procedure TMyWord.WriteText(Text: string); begin try //connectword(); FWord.Selection.TypeText(Text); except //防止呼叫失败 WriteText(Text); end; end; //按样式插入一行记录 //如AddLine "备注","正文" //AddLine ''kk'',"标题 1" procedure TMyWord.AddLine(S: string; PStyle: olevariant); procedure SetStyle(PStyle: olevariant); var outStyle: Style; v: olevariant; begin outStyle := FWord.ActiveDocument.Styles.Item(PStyle); v := outStyle; FWord.Selection.Set_Style(v); end; begin WriteText(S); //加入一行 try SetStyle(PStyle); except SetStyle(PStyle); end; end; procedure TMyWord.AlignLine(Align: ToleEnum); begin FWord.Selection.ParagraphFormat.Alignment := Align; end; //插入分页符 procedure TMyWord.insertPage(); var _Type: olevariant; begin _Type := 7; FWord.Selection.InsertBreak(_Type); end; //插入日期 procedure TMyWord.insertDate(); var DateTimeFormat: olevariant; InsertAsField: olevariant; InsertAsFullWidth: olevariant; DateLanguage: olevariant; CalendarType: olevariant; begin try InsertAsField := False; InsertAsFullWidth := False; DateTimeFormat := ''yyyy''''年''''M''''月''''d''''日''''''; DateLanguage := wdSimplifiedChi