Control Reference > VSPrinter Control > VSPrinter Methods > MovePages Method |
Moves a group of pages to the start or to the end of the document.
[form!]VSPrinter.MovePages First As Long, Last As Long, bToFront As Boolean
This method is useful mainly for documents that have a table of contents or similar elements that can only be created after the body of the document is done, but which you would like to insert at the start of the document.
For example, the code below creates a long document, followed by a table of contents. It then moves the table of contents to the beginning of the document:
With vp
.StartDoc
' create document body
Dim i%, s$
s = "This is a very long paragraph. "
s = s & s & s & s & s & s
s = s & s & s
vp.Paragraph = "** Document Body"
For i = 1 To 200
.Paragraph = s
Next
' create table of contents
vp.NewPage
Dim fp%
fp = vp.PageCount
vp.Paragraph = "** Table Of Contents"
For i = 1 To 100
vp = "Item " & i & "...... Page n"
Next
vp.EndDoc
' move TOC to doc start
vp.MovePages fp, vp.PageCount, True
End With