Workbook.InsertObject
Use this function to insert the specified object into the workbook.
| Syntax | Parameters | Return value |
|---|---|---|
Function Workbook.InsertObject( _
Object As Object, _
ItemReference As WorkbookItem, _
Optional Placement As WorkbookPlacement = scWorkbookDefaultPlacement) As WorkbookItem
|
|
SVB Example
Inserting an 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")
Dim M As Macro
'assigns the new macro to the object M
Set M = Macros.New("Example Macro")
'inserts the object, M, into the root folder of the workbook As the last child
wb.InsertObject(M,wb.Root,scWorkbookLastChild)
'sets the workbook to visible
wb.Visible = True
End Sub