我正在尝试为单词编写一个vba宏,其中文档将具有页码,但奇数页码的对齐方式将与偶数页面不同。我目前正在尝试的代码是改变奇数页和偶数页的对齐,这是不希望的
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
答案 0 :(得分:2)
对于奇数页和偶数页,您似乎没有设置页码的left
和right
位置,但您需要设置它们的outside
和inside
个位置
所以,试着改变这条小线:
.Add (0)
进入一个可能的'奇偶'位置:
.Add wdAlignPageNumberOutside
.Add wdAlignPageNumberInside
此外,不需要尝试插入'tab'的最后一行。