Understanding Discussions

This content is no longer actively maintained. It is provided as is, for anyone who may still be using these technologies, with no warranties or claims of accuracy with regard to the most recent product version or service release.

The Discussions collection contains all the Discussion objects associated with each level of discussion on a page. In turn, each Discussion object might have a Discussions collection that contains the Discussion objects related to that level of discussion.

A Discussion object represents an entry in a discussion. Each Discussion object has properties and methods you can use to specify the information that appears in the discussion, as well as how and when changes are made to a discussion. Several of these properties map directly to settings you can specify in Discussion fields of the Discussion Options dialog box.

You add a Discussion object to a Discussions collection by using the Discussions collection's Add method. You remove a Discussion object from a Discussions collection by using the Discussion object's Delete method.

The following code illustrates one technique you can use to get some basic information about the number of top-level discussions on a page:

Sub DisplayDiscussionInfo(strURL As String)
   Dim colDiscussions As Discussions
   Dim dscCurrent As Discussion
   Dim strMessage As String
   
   Set colDiscussions = OSE.OpenDiscussions(strURL)
   If colDiscussions.Count = 0 Then
      strMessage = "The page '" & strURL _
         & "' has no discussions."
   Else
      strMessage = "The page '" & strURL _
         & "' has " & colDiscussions.Count _
         & " discussions." & vbCrLf & vbCrLf
      For Each dscCurrent In colDiscussions
         With dscCurrent
            strMessage = strMessage _
               & "The top-level discussion number " _
               & .Index & " " _
               & IIf(.Discussions.Count > 0, "has one or more", _
               "does not have") & " replies." & vbCrLf
         End With
      Next dscCurrent
   End If
   MsgBox strMessage
End Sub

Each Discussion object in the Discussions collection represents a message in a discussion thread. If a page has a single message, the Discussions collection will contain a single Discussion object representing that message. If there are replies to a message, the Discussion object's Discussions property will return the collection of all replies to that message. This pattern is repeated for every Discussion object in a thread that has replies. The following figure illustrates the relationship between a Discussions collection and the Discussion objects it contains:

Relationship between Discussions Collections and Discussion Objects

Aa141347.01212(en-us,office.10).gif

The Discussions collection for this page contains one Discussion object. That Discussion object's Discussions property would return a Discussions collection containing two Discussion objects, and so on. The following code sample illustrates how you would refer to the message entitled "This is another reply to a reply." In this example, the colDiscussions variable represents the Discussions collection returned by the OpenDiscussions method:

With colDiscussions(1).Discussions(1).Discussions(2)
   MsgBox .Subject & " added to page at: " & .Timestamp
End With

See Also

Using Web Technologies with Office XP | Working with Office Web Discussions Client | The Office Web Discussions Client Object Model | Enabling Discussions | Understanding the Global Object | Understanding Discussion Servers | Understanding Subscriptions