Add Method

Adds a new image to the Images collection of a document.

expression.Add(Page, BeforePage)

*expression   * Required. An expression that returns an Images collection.

Page    Required Object. The new page to be added.

BeforePage    Required Object. The page in front of which to add the new image. Use Nothing to add the new image as the last page or to add the new image to an empty document.

Example

The following example opens a multipage source document and creates a new empty destination document. After the empty destination document is created, the example does the following:

  1. Adds the first image from the source to the new empty document by passing Nothing as BeforePage.
  2. Adds the third image from the source to the end of the new document by passing Nothing again as BeforePage.
  3. Adds the second image from the source between the first and last pages of the new document by passing the existing second page as BeforePage.

The result is a new document in which the first three pages from the source document appear in the same order.

Sub TestAdd()

  Dim miDocSrc As MODI.Document
  Dim miDocDest As MODI.Document
  
  Set miDocSrc = New MODI.Document
  Set miDocDest = New MODI.Document
  miDocSrc.Create "C:\document1.tif"
  miDocDest.Create
  
  With miDocDest.Images
    .Add miDocSrc.Images(0), Nothing
    .Add miDocSrc.Images(2), Nothing
    .Add miDocSrc.Images(1), miDocDest.Images(1)
  End With

  miDocDest.SaveAs "C:\document2.mdi", miFILE_FORMAT_MDI
  
  Set miDocDest = Nothing
  Set miDocSrc = Nothing

End Sub

Applies to | Images Collection Object