Workbook.NextItem
Use this property to sets the focus to the next item in the workbook. This property is read only.
| Syntax | Parameters | Return value |
|---|---|---|
ReadOnly Property Workbook.NextItem( _
Item As WorkbookItem) As WorkbookItem
|
Item [in]
Type: |
SVB Example
Looping through items in a workbook
Option Base 1
Option Explicit
Sub Main
Dim w As Workbook
Set w = ActiveWorkbook
'set the pointer to the beginning of the workbook tree
Dim CurrentItem As WorkbookItem
Set CurrentItem = w.Root
'loop until you reach the last node in the workbook tree
Do While TypeName(CurrentItem) <> "Nothing"
Set CurrentItem = w.NextItem(CurrentItem)
'the last node in the workbook tree has been reached.
If TypeName(CurrentItem) = "Nothing" Then Exit Do
'if it's a spreadsheet then print it
If CurrentItem.Type = scWorkbookItemTypeSpreadsheet Then
CurrentItem.Activate
w.PrintOut(True, False)
End If
Loop
End Sub
Copyright © 2020. Cloud Software Group, Inc. All Rights Reserved.
