excel页眉页脚中怎样插入公式?
来源:百度知道 编辑:UC知道 时间:2024/05/04 13:42:42
有哪位高手知道如何处理?请指教,先谢谢啦!
很感谢xiehuahere的回答。如果是在word页眉中,容易实现我说的那种效果。除了xiehuahere和编程外,也可以用域来实现,方法是:
1、进入页眉栏中,输入“第批体检名单”
2、然后将光标挪到“第”后面,按“ctrl + F9”组合,插入域。
3、在域的中括号中输入“=int("页码"/3+0.7)”。注:括号中的“页码”要通过点击“页眉和页脚”中的“插入页码”实现输入。
4、将光标放到域的大括号中,点右键,选择“更新域”即可。
利用分节符可以实现不同页眉的显示。可以用一个宏来自动完成。
Sub test()
Dim pageNum As Long
Dim sectionNum As Long
Selection.HomeKey unit:=wdStory
With Selection.Find
.ClearFormatting
.Execute findText:="^b", ReplaceWith:="", Replace:=wdReplaceAll, Format:=False, Forward:=True, Wrap:=wdFindContinue
End With
ActiveDocument.Repaginate
pageNum = ActiveDocument.BuiltInDocumentProperties(wdPropertyPages)
sectionNum = 0
For i = 1 To pageNum
If i Mod 3 = 0 Then
Selection.GoTo What:=wdGoToPage, Which:=wdGoToNext, Name:=(i + 1)
Selection.MoveUp unit:=wdLine, Count:=1
Selection.EndKey unit:=wdLine
Selection.InsertBreak Type:=wdSectionBreakNextPage 'wdSectionBreakContinuous
sectionNum = sectionNum + 1
End If
Next i