Vba 在word中指定奇偶页码
我正在尝试为word编写vba宏,其中文档将有页码,但奇数页码的对齐方式将不同于偶数页。我目前正在尝试的代码是更改奇数页和偶数页的对齐方式,这是不需要的Vba 在word中指定奇偶页码,vba,ms-word,page-numbering,Vba,Ms Word,Page Numbering,我正在尝试为word编写vba宏,其中文档将有页码,但奇数页码的对齐方式将不同于偶数页。我目前正在尝试的代码是更改奇数页和偶数页的对齐方式,这是不需要的 ActiveDocument.Sections(i).PageSetup.OddAndEvenPagesHeaderFooter = False ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter Selection.HeaderFooter.L
ActiveDocument.Sections(i).PageSetup.OddAndEvenPagesHeaderFooter = False
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
Selection.HeaderFooter.LinkToPrevious = Not Selection.HeaderFooter.LinkToPrevious
ActiveDocument.Sections(i).Footers(wdHeaderFooterPrimary).LinkToPrevious = False
With ActiveDocument.Sections(i).Footers(1).PageNumbers
.NumberStyle = wdPageNumberStyleArabic
.HeadingLevelForChapter = 0
.IncludeChapterNumber = False
.ChapterPageSeparator = wdSeparatorHyphen
.RestartNumberingAtSection = False
.StartingNumber = starts
.Add (0)
End With
End If
ActiveDocument.Sections(i).PageSetup.OddAndEvenPagesHeaderFooter = True
ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
ActiveDocument.Sections(i).Footers(wdHeaderFooterEvenPages).LinkToPrevious = False
WordBasic.InsertAlignmentTab Alignment:=2, Relative:=0, Leader:=0
对于奇数页和偶数页,您似乎没有设置页码的
左
和右
位置,但需要设置页码的外部
和内部
位置
所以,试着改变这条细线:
.Add (0)
进入一个可能的“奇偶”位置:
.Add wdAlignPageNumberOutside
.Add wdAlignPageNumberInside
此外,尝试插入“tab”的最后一行是不必要的。如何定义
no_format
变量??以及其他变量,如开始
,继续
,对齐
??您是否尝试一步一步地调试此代码??此外,在代码中添加更大的部分,其中包括在结尾前第5行的end if
语句的开头…no_format是表示页码样式的变量=1,continue是true,如果继续使用上一节标记页面,continue是false,和align=0表示左对齐,align2表示右对齐,如果endif用于在页眉或页脚中定位页码,则这些是重要信息。你能把你的代码扩展一点吗?希望它是固定的。任何反馈,如果它的工作是欢迎的。。。