Microsoft Office 2000/Visual Basic Programmer's Guide   

Understanding Discussion Servers

The DiscussionServers collection contains all the DiscussionServer objects that represent each discussion server registered on your machine. You can also view this collection in the Select a discussion server box in the Discussion Options dialog box (shown in Figure 12.11). A DiscussionServer object is used to store discussion items for any document. Typically, a workgroup would agree to use a specific discussion server so that all members of the group will be able to see each other's comments.

Figure 12.11 The Discussion Options Dialog Box

You use the DiscussionServers collection's Add method to add a new DiscussionServer object to the list of discussion servers registered on your machine. The Add method requires values for both the ServerName and the FriendlyName arguments. These arguments map directly to the settings you provide in the Add or Edit Discussion Servers dialog box, which you open by clicking the Add or Edit button in the Discussion Options dialog box. The default discussion server is represented by the DiscussionServers(1) DiscussionServer object. You can make any DiscussionServer object the default by using the object's SetAsDefault method, which re-sorts the collection of DiscussionServer objects. You remove a DiscussionServer object by using the object's Delete method.

The following code shows how to determine the number of discussion servers registered on the current machine:

Sub DisplayDiscussionServerInfo()
   Dim strCountMessage        As String
   Dim strServerInfo          As String
   Dim dscCurrentServer       As DiscussionServer

   strCountMessage = "There are " & OSE.DiscussionServers.Count _
      & " discussion servers registered on this machine." & vbCrLf
   If OSE.DiscussionServers.Count > 0 Then
      For Each dscCurrentServer In OSE.DiscussionServers
         With dscCurrentServer
            strServerInfo = strServerInfo & "Name = " & .FriendlyName _
               & ", Address = " & .ServerAddress & "." & vbCrLf
         End With
      Next dscCurrentServer
   Else
      strServerInfo = ""
   End If
   MsgBox strCountMessage & strServerInfo
End Sub