读书人

用delphi控制word怎么替换word中页眉

发布时间: 2013-07-04 11:45:44 作者: rapoo

用delphi控制word,如何替换word中页眉文字,或者设置页眉
如题,我想用delphi控制word,如何替换word中页眉文字?
[解决办法]
调用word功能,先搜索,再替换,可参考:
var
FindText, MatchCase, MatchWholeWord, MatchWildcards, MatchSoundsLike,
MatchAllWordForms, Forward, Wrap, Format, ReplaceWith, Replace: OleVariant;
begin
FindText := '<#Name>';
MatchCase := False;
MatchWholeWord := True;
MatchWildcards := False;
MatchSoundsLike := False;
MatchAllWordForms := False;
Forward := True;
Wrap := wdFindContinue;
Format := False;
ReplaceWith := 'Delphi';
Replace := True;

WordDocument.Range.Find.Execute( FindText, MatchCase, MatchWholeWord,
MatchWildcards, MatchSoundsLike, MatchAllWordForms, Forward,
Wrap, Format, ReplaceWith, Replace );

end;
[解决办法]
用Word录制个宏,参考宏里面的代码
[解决办法]
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
ActiveDocument.AttachedTemplate.BuildingBlockEntries(" 空白").Insert Where:= _
Selection.Range, RichText:=True
Selection.TypeText Text:="就这样明白吧"
ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument

这是vb的转下delphi 一看就知吧

读书人网 >.NET

热点推荐