'INSPAGE.BAS

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Insert a page before an active one                                  '
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Function Main As String
Dim Page, Drawings, DObj, Temp As Object
Dim ActivePageIndex, I, NPages As Integer

  With ActiveDocument
    NPages = .Count
    If NPages > 99 Then
      Main = "Cannot insert a page." + Chr(13) + Chr(13) + "Document cannot contain more than 100 pages."
      Exit Function
    End If
    ActivePageIndex = .Index(.ActivePage)
    Page = .AddEmpty
    NPages = NPages + 1
    For I = NPages To ActivePageIndex + 1 Step -1
      Drawings = .Item(I - 1).Drawings
      Temp = Drawings.LoadOnto(.Item(I))
      If Temp <> NULL Then
        For Each DObj In Drawings
          Kill(DObj)
        Next DObj
      End If
      .Item(I).SetName(.Item(I - 1).GetName)
    Next I
    .Item(ActivePageIndex).SetName("")
    .SetActivePage(.Item(ActivePageIndex))
  End With
  Main = "New page is inserted."

End Function
