简体   繁体   English

如何使用delphi xe5更改word中页码的字体

[英]How to change the font of the page numbers in word using delphi xe5

I am automating word documents.我正在自动化 Word 文档。 Generating them solely from code.仅从代码生成它们。

Currently i am adding a page number in the header of each page, But i would like to know how to change the font name of the page number along with the font size.目前我正在每页的标题中添加一个页码,但我想知道如何更改页码的字体名称以及字体大小。

Any help would be appreciated.任何帮助,将不胜感激。

Please note, wrddoc is the active document variable.请注意,wrddoc 是活动文档变量。

here is the code i create the page number with: wrdDoc.Sections[1].Headers[1].PageNumbers.Add(wdAlignPageNumberRight);这是我创建页码的代码: wrdDoc.Sections[1].Headers[1].PageNumbers.Add(wdAlignPageNumberRight);

And i tried the following code to change the font but i get an error, "method font is not a supported automation object":我尝试了以下代码来更改字体,但出现错误“方法字体不是受支持的自动化对象”:

wrdDoc.Sections[1].Headers[1].PageNumbers.Font.name:='Times New Roman';
wrdDoc.Sections[1].Headers[1].PageNumbers.Font.Size:=12;

Any help would be appreciated thank you.任何帮助将不胜感激,谢谢。

It works for me:这个对我有用:

wrdDoc.Sections.First.Headers.Item(1).Range.Font.Name := 'Times New Roman';
wrdDoc.Sections.First.Headers.Item(1).Range.Font.Size:= 12;

Delphi XE, Office 2010.德尔福 XE,Office 2010。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM