Example: Displaying the history for a VOB object in Microsoft Excel

To run this sample application:

  1. Start Excel.
  2. Click Tools > Macro > Macros.
  3. Enter a name for the macro and click Create. This starts the VBA IDE.
  4. In the VBA IDE, click Tools > References and set ClearCase Automation Libraryx.x. Then click OK.
  5. Copy the code in Example and paste it into the macro source windows (between Sub name() and End Sub)
  6. Edit the code to replace <path> with the view-extended path of a versioned file in a VOB. For example, \\view\view-name\vob-name\rest-of-path.
  7. Run the example. (Click Run Sub, the right-pointing blue triangle on the toolbar).
  8. Return to the spreadsheet to view the history information.

Example

' Set up column headers
Dim xlsheet As Excel.Worksheet
Set xlsheet = ThisWorkbook.Worksheets(1)
With xlsheet
     .Cells(5, 1) = "Date"
     .Cells(5, 2) = "UserLoginName"
     .Cells(5, 3) = "Host"
     .Cells(5, 4) = "Event Kind"
     .Cells(5, 5) = "Comment"
End With

' Connect to the top-level ClearCase object
Dim CC as New ClearCase.Application
Dim Elem as CCElement
Dim Record as CCHistoryRecord
Dim Records as CCHistoryRecords
Set Elem = CC.Element("<path>")

' Get the history records via the ICCVOBObject interface
Set Records = Elem.HistoryRecords(Nothing)
Dim I As Integer
I = 6
For Each Record In Records
     ' Left hand side of assignments below are Excel objects;
     ' Right hand side are CAL objects
     With xlsheet
          .Cells(I, 1) = Record.Date
          .Cells(I, 2) = Record.UserLoginName
          .Cells(I, 3) = Record.Host
          .Cells(I, 4) = Record.EventKind
          .Cells(I, 5) = Record.Comment
     End With
     I = I + 1
Next

' Format the worksheet
xlsheet.UsedRange.Select
Selection.AutoFormat
xlsheet.Cells(1, 1).Select

Feedback