需要跳过包含文本Word Macro的行 [英] need to skip the line that contains the text Word Macro

查看:74
本文介绍了需要跳过包含文本Word Macro的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须打印文档,它需要的是:

I have to print documents and what it requires is:

  1. 摘要页应该在单页上打印(实际上总是在一页上),但是下一页会在其背面打印,即版税摘要.因此,我们在每个使用宏"的摘要"页之后添加了一个空白页.
  2. 如果"Royalty"以奇数结尾(例如,从第2页开始到3结束表示总共3页),则需要添加一个空白页.因此,下一个摘要部分将开始在新页上而不是在结束页的背面打印.

我到目前为止所写的内容如下:

what i have write till now is as below:

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

它可以正常工作,但是公司名称在摘要"或专利使用费"进入空白页之前位于同一行.这是我得到的输出图片:

It works fine, but the company name i have in same line before the "Summary" or "Royalty" gets on the blank page. here is the pic of the output i am getting:

我不知道该如何解决,公司名称应保留在同一页面上.中间应包含空白页.请帮忙.

I'm not getting how this can be fixed, company name should remain on same page. should include blank page in between. please help.

推荐答案

只需使用正确的分页符就可以在奇数页或偶数页上开始下一页,并且不需要宏即可添加空白页.

Just use the correct page break to start next page on an odd or even page and you will need no macro to add blank pages.

这篇关于需要跳过包含文本Word Macro的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆