Public Function makeConnection( qcDomain$, qcProject$, _ qcUser$, qcPassword$, Optional qcPort) As Boolean ' Connect and log on '------------------------------------------------------------------------ ' This routine makes the connection to the gobal TDConnection object ' (declared at the project level as "Global tdc as TDConnection") ' and connects the user to the specified project. ' At each stage, there are commented calls to various properties. ' Under the calls, are the output you would get if you ran the ' property calls. '----------------------------------------------------------------------- Dim qcServer As String Const fName = "makeConnection" 'For error message On Error GoTo makeConnectionErr errmsg = "" ' Check status (for demonstration purposes only). ' MsgBox tdc.LoggedIn ' MsgBox tdc.Connected ' MsgBox tdc.ServerName 'Blank string ' Output: ' Error: OTA Server is not connected ' False ' Blank string ' Create the connection. errmsg = "Failed to create TDConnection" If (tdc Is Nothing) Then Set tdc = New TDConnection If (tdc Is Nothing) Then GoTo makeConnectionErr errmsg = "" ' Check status ' On Error Resume Next ' Debug.Print "Initial Status: " ' Debug.Print "LoggedIn", """" & tdc.LoggedIn & """" ' Debug.Print "LoggedIn Error", err.Description ' Debug.Print "Connected", """" & tdc.Connected & """" ' Debug.Print "ServerName", """" & tdc.ServerName & """" ' Debug.Print "ProjectName", """" & tdc.ProjectName & """" ' Debug.Print "ProjectName Error", err.Description ' Debug.Print "ProjectConnected", """" & tdc.ProjectConnected & """" ' Debug.Print "ProjectConnected Error", err.Description ' Debug.Print ' On Error GoTo makeConnectionErr ' ' Initial Status - Output of above calls: ' LoggedIn Error OTA server is not connected. ' Connected "False" ' ServerName "" ' ProjectName Error OTA server is not connected. ' ProjectConnected Error OTA server is not connected. tdc.InitConnectionEx "http://myALMServer:8080/qcbin" ' Check status. ' On Error Resume Next ' Debug.Print "After InitConnectionEx: " ' Debug.Print "LoggedIn", """" & tdc.LoggedIn & """" ' Debug.Print "Connected", """" & tdc.Connected & """" ' Debug.Print "ServerName", """" & tdc.ServerName & """" ' Debug.Print "ProjectName", """" & tdc.ProjectName & """" ' Debug.Print "ProjectConnected", """" & tdc.ProjectConnected & """" ' Debug.Print ' ' After InitConnectionEx - Output of above calls: ' LoggedIn "False" ' Connected "True" ' ServerName "http://server06/qcbin/wcomsrv.dll" ' ProjectName "" ' ProjectConnected "False" ' Log on to server. tdc.Login qcUser, qcPassword ' Check status. ' Debug.Print "After Login: " ' Debug.Print "LoggedIn", """" & tdc.LoggedIn & """" ' Debug.Print "Connected", """" & tdc.Connected & """" ' Debug.Print "ServerName", """" & tdc.ServerName & """" ' Debug.Print "ProjectName", """" & tdc.ProjectName & """" ' Debug.Print "ProjectConnected", """" & tdc.ProjectConnected & """" ' Debug.Print ' After Login - Output of above calls: ' LoggedIn "True" ' Connected "True" ' ServerName "http://server06/qcbin/wcomsrv.dll" ' ProjectName "" ' ProjectConnected "False" ' Connect to the project and user. tdc.Connect qcDomain, qcProject ' Exit status. ' Debug.Print "After Connect: " ' Debug.Print "LoggedIn", """" & tdc.LoggedIn & """" ' Debug.Print "Connected", """" & tdc.Connected & """" ' Debug.Print "ServerName", """" & tdc.ServerName & """" ' Debug.Print "ProjectName", """" & tdc.ProjectName & """" ' Debug.Print "ProjectConnected", """" & tdc.ProjectConnected & """" ' Debug.Print ' ' After Connect - Output of above calls: ' LoggedIn "True" ' Connected "True" ' ServerName "http://server06/qcbin/wcomsrv.dll" ' ProjectName "ota_doc" ' ProjectConnected "True" makeConnection = True Exit Function makeConnectionErr: makeConnection = False End Function