如何反转所有页面顺序,因此将1,2,3,4,5页面变成5,4,3,2,1,就像Option一样。打印时反转。
为
Sub test()
Dim WA As Object, WD As Object
Dim rngDoc As Word.Range, rngInsert As Word.Range
Set WA = CreateObject("Word.Application")
Set WD = WA.Documents.Add(TemplatesName)
Set rngDoc = WD.Content
Set rngInsert = rngDoc.Duplicate
For i = 1 To 100
With rngInsert
.InsertBreak Type:=wdSectionBreakNextPage
.MoveEnd Unit:=wdCharacter, Count:=-1 ' this one reversing pages
.InsertFile TemplatesName
End With
Next i
WD.SaveAs PdfFile, 17
WD.Close False: Set WD = Nothing
WA.Quit False: Set WA = Nothing
End Sub
以反向顺序插入页面,我需要将它们反向反转
Option.reverse与
WA.PrintOut OutputFileName:=PdfFile, Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentWithMarkup, Copies:=1, Pages:="", PageType:= _
wdPrintAllPages, Collate:=True, Background:=True, PrintToFile:=True, _
PrintZoomColumn:=0, PrintZoomRow:=0, PrintZoomPaperWidth:=0, _
PrintZoomPaperHeight:=0
执行我需要的操作,但是在这里会警告有关错误的页边距,因此,如果我将displayalert设置为False,则文档将不保存。
答案 0 :(得分:1)
如果您要这样做,则可以通过以下方式反转打印顺序:
Options.PrintReverse = True
但是,如果问题是您以错误的顺序插入页面,则需要如下代码:
Sub Demo()
Dim wdApp As New Word.Application, wdDoc As Word.Document
Dim wdRng As Word.Range, i As Long
Const TemplatesName As String = "Template Path & name"
Set wdDoc = wdApp.Documents.Add(TemplatesName)
Set wdRng = wdDoc.Range
For i = 1 To 10
With wdRng
.InsertAfter vbCr
.Start = wdDoc.Range.End
.InsertBreak Type:=wdSectionBreakNextPage
.Collapse wdCollapseEnd
.InsertFile TemplatesName
End With
Next i
End Sub