Workbook.InsertNew

Use this function to insert a new document or folder into the workbook.

Syntax Parameters Return value
Function Workbook.InsertNew( _
    ItemType As Variant, _
    ItemReference As WorkbookItem, _
    Optional Placement As WorkbookPlacement = scWorkbookDefaultPlacement) As WorkbookItem
  • ItemType [in]

    The type of item to insert into the workbook. The following constants can be used as arguments for this parameter: scWorkbookItemTypeFolder, scWorkbookItemTypeSpreadsheet, scWorkbookItemTypeReport, scWorkbookItemTypeMacro, scWorkbookItemTypeGraph.

    Type: Variant

  • 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

Inserting a new item into 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 a new report document, into the root folder of the
    'workbook as the first child
    wb.InsertNew(scWorkbookItemTypeReport,wb.Root,scWorkbookFirstChild)
    'sets the workbook to visible
    wb.Visible = True
End Sub