Previous Document Next Document
Workspaces.Item

Property Item(IndexOrName As Variant) As Workspace

Member of Workspaces

The Item property returns a reference to a workspace in the collection.

The Item property is the default property, and its reference can be omitted when accessing items in the collection. For example, Workspaces.Item(2) is the same as Workspaces(2) — they both reference the second workspace in the Workspaces collection.

returns a read-only value.

Parameters
Description
IndexOrName
Specifies the view by its index number or name:
Index — Acts as a preset placeholder for each object in the Workspaces collection, uniquely identifying each member of the collection
Name — Represents the unique string value that identifies each workspace

The following code example displays a message box that lists the names of the workspaces:

Sub Test() 
 Dim intCounter As Integer 
 Dim Ws As Workspace 
 Dim s As String 
 For intCounter = 1 To Workspaces.Count 
  Set Ws = Workspaces(intCounter) 
  s = s & Ws.Name & vbCr 
 Next intCounter 
 MsgBox "The current document contains the following workspaces: " 
& vbCr & s 
 Set Ws = Nothing 
End Sub 

The following code example performs the same procedure as the previous example. However, instead of using a For Next command, it uses the For Each command in Visual Basic to iterate through all of the workspaces in the collection.

Sub Test() 
 Dim Ws As Workspace 
 Dim s As String 
  For Each Ws In Workspaces 
   s = s & Ws.Name & vbCr 
  Next Ws 
 MsgBox "The current document contains the following workspaces: " 
& vbCr & s 
 Set Ws = Nothing 
End Sub 

Previous Document Next Document Back to Top

Copyright 2007 Corel Corporation. All rights reserved.