Workbook.InsertFile

Use this function to inserts the specified file into the workbook.

Syntax Parameters Return value
Function Workbook.InsertFile( _
    FileName As String, _
    ItemReference As WorkbookItem, _
    Optional Placement As WorkbookPlacement = scWorkbookDefaultPlacement) As WorkbookItem
  • FileName [in]

    File to insert.

    Type: String

  • ItemReference [in]

    Which item in the workbook should be used as the parent or sibling of the inserted file. The Placement parameter determines whether the inserted file is a parent or sibling of this item.

    Type:

  • Placement [in, optional]

    Integer value specifying how to place the file into the workbook with regards to the specified ItemReference.

    Type:

    Default value:

SVB Example

Copying and pasting items from a workbook

Option Base 1
Option Explicit
Sub Main
    Dim wb As Workbook
    ' assigns the new workbook to the object wb
    Set wb = Workbooks.New("WB Example")
    'inserts the file adstudy.sta into the root folder 
    'of the workbook as the first child
    wb.InsertFile(Path & _
        "\examples\datasets\adstudy.sta",wb.Root,scWorkbookFirstChild)
    'sets the workbook to visible
    wb.Visible = True
    'copies the current item in the workbook (spreadsheet adstudy.sta)
    wb.Copy
    Dim R As Report
    'assigns the new report to the object R
    Set R = Reports.New("Report Example")
    'pastes the data located on the clipboard to the report
    r.Paste
    r.Visible = True
End Sub