【发布时间】:2019-06-24 10:31:34
【问题描述】:
我必须打印文件,它需要的是:
- 摘要页应打印在单页上(实际上总是单页),但下一页打印在它的背面,即版税摘要。所以我们使用宏在每个摘要页面之后添加了一个空白页面。
- 如果“Royalty”以奇数结尾(例如从第 2 页开始,以 3 结尾表示总共 3 页),则需要添加一个空白页。因此,下一个摘要部分将在新页面上开始打印,而不是在结束页面的背面。
我到现在写的如下:
Sub Test()
InsertSectionBreaks "S U M M A R Y "
InsertSectionBreaks "R O Y A L T Y "
End Sub
Sub InsertSectionBreaks(FindText As String)
Dim FindRange As Word.Range, SectionRange As Word.Range
Dim Found As Boolean
Set FindRange = ActiveDocument.Content
' Find next section based on text, insert odd page section break just before
FindRange.Find.ClearFormatting
With FindRange.Find
.Text = FindText
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindStop
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
Found = .Execute
End With
Do While Found
'avoid adding a section break at beginning of document
If FindRange.Information(wdActiveEndAdjustedPageNumber) > 1 Then
Set SectionRange = FindRange.Duplicate
SectionRange.Collapse wdCollapseStart
SectionRange.InsertBreak Type:=wdSectionBreakOddPage
End If
FindRange.Collapse wdCollapseEnd
Found = FindRange.Find.Execute
Loop
End Sub
它工作正常,但在“摘要”或“版税”进入空白页之前,我在同一行中的公司名称。这是我得到的输出图片:
我不知道如何解决此问题,公司名称应保留在同一页面上。应该包括中间的空白页。请帮忙。
【问题讨论】: