Example: Displaying the projects and folders in the project tree

' Displaying the projects and folders in the project tree

Private Function FolderInfo(Folder As CCFolder, TabStr As String) As String

Dim StrProj As String
StrProj = vbCrLf & TabStr & "Folder " & Folder.Title & " contains: " & vbCrLf

' Process all the subfolders recursively
If Folder.SubFolders.Count <> 0 Then
    Dim ChildFolder As CCFolder
    For Each ChildFolder In Folder.SubFolders
        StrProj = StrProj & FolderInfo(ChildFolder, TabStr & vbTab)
    Next
End If

' Gather the titles of all the projects in a folder and add level spacing

Dim Projects As CCProjects
Set Projects = Folder.Projects
If Projects.Count <> 0 Then
	StrProj = StrProj & vbCrLf
	For Each Project In Projects
		StrProj = StrProj & TabStr & Project.Title & vbCrLf
	Next
Else
	StrProj = StrProj & TabStr & "no projects" & vbCrLf
End If
FolderInfo = StrProj
End Function

' Connect to top-level object

Dim CC As New ClearCase.Application

' Get the project VOB with tag \projects
Dim PVOB As CCProjectVOB
On Error Resume Next
Set PVOB = CC.ProjectVOB("\projects")
If Err.Number <> 0 Then
	MsgBox "CC.ProjectVOB returned error: " & Err.Description
Else
	' Get the root folder in the project VOB
	Dim Folder As CCFolder
	On Error Resume Next
	Set Folder = PVOB.RootFolder
	If Err.Number <> 0 Then
		MsgBox "PVOB.RootFolder returned error: " & Err.Description
	Else
		MsgBox "Projects contained in the project tree" & _
			vbCrLf & FolderInfo(Folder, "")
	End If
End If

Feedback