*编号:A0034
*功能:VFP控制Word文档添加页眉和页脚(二)
LOCAL loWordApp
loWordApp=CREATEOBJECT("word.application")
WITH loWordApp
.Visible=.T.
.documents.Add
.Selection.TypeText("这是个测试如何转换成VF语言")
if .ActiveWindow.View.SplitSpecial<>0 Then
.ActiveWindow.View.Panes(2).Close
endif
if .ActiveWindow.ActivePane.View.Type=1 or;
.ActiveWindow.ActivePane.View.Type=2 Then
.ActiveWindow.ActivePane.View.Type=9
endif
.ActiveWindow.ActivePane.View.SeekView=1
if .Selection.HeaderFooter.ISHeader=.T. Then
.ActiveWindow.ActivePane.View.SeekView=10
else
.ActiveWindow.ActivePane.View.SeekView=8
endif
.NormalTempPlateAutoTextEntries("第X页 共Y页").Insert(.Selection.Range)
.ActiveWindow.ActivePane.View.SeekView=1
.Selection.TypeText("红虎工作室(honghoo.net)制作")
ENDWITH
添加页脚可简化为:
LOCAL loWordApp
loWordApp=CREATEOBJECT("word.application")
WITH loWordApp
.Visible=.T.
.documents.Add
.Selection.TypeText("这是个测试如何转换成VF语言")
.ActiveWindow.ActivePane.View.SeekView=10
.NormalTempPlateAutoTextEntries("第X页 共Y页").Insert(.Selection.Range)
.Selection.ParagraphFormat.Alignment=1 &&页脚居中
ENDWITH |
|