Output all bug links
Public Sub ViewLinks()

' Output all bug links

    Dim BugF As BugFactory, bList As List
    Dim aBug As Bug
    Dim bugL As ILinkable, LinkList As List, linkF As LinkFactory
'tdc is the global TDConnection object.
    Set BugF = tdc.BugFactory
    Set bList = BugF.NewList("")
    For Each aBug In bList
'Cast the Bug object to an ILinkable reference
' to get the link factory.
        Set bugL = aBug
        Set linkF = bugL.LinkFactory
        Set LinkList = linkF.NewList("")
        Dim SourceObj As Object, TargetObj As Object, InitObj As Object, lnk As Link
        Debug.Print: Debug.Print "---------------------------------"
        Debug.Print "Source Type"; Tab; "ID"; Tab; "Target Type"; _
            Tab; "ID"; Tab; "Initiated by"
        For Each lnk In LinkList
            With lnk
                Set SourceObj = .SourceEntity
                Set TargetObj = .TargetEntity
                Set InitObj = .LinkedByEntity
                Debug.Print TypeName(SourceObj); Tab; CStr(SourceObj.ID); _
                    Tab; TypeName(TargetObj); Tab; CStr(TargetObj.ID); _
                    Tab; TypeName(InitObj); Spc(3); InitObj.ID
            End With
        Next lnk
    Next aBug
End Sub

Defect to defect links