Why does GetObject method open two instances of an application at once?
I'm using VBA within Excel to launch a client instance of IBM Rational DOORS and connect to it. This used to work correctly, but recently our IT department rolled out some enterprise-wide Windows updates and now we see a problem where two instances of DOORS are launched when the GetObject method is invoked. The three most recent updates were the following:
- August 8, 2023-KB5029649 Cumulative Update for .NET Framework 3.5, 4.8 and 4.8.1 for Windows 10 Version 22H2
- August 8, 2023—KB5029244 (OS Builds 19044.3324 and 19045.3324)
- July 11, 2023—KB5028166 (OS Builds 19044.3208 and 19045.3208)
A fragment of the VB code we are using follows below:
Const APP_ID As String = "DOORS.Application" 'ID string used for CreateObject()
Dim m_doorsAppObj As Object 'Module-level object variable to hold instance of DOORS application
...
Public Function DOORS_Login(Optional Reconnect As Boolean) As Integer
Dim PWStatus As Integer
Dim LoginStatus As Integer
Dim SendStr As String
Dim UsrInfo As String
If IsMissing(Reconnect) Then
Reconnect = False
End If
On Error GoTo ErrSvc
UsrInfo = DOORS_UserID() 'Get logged-in user ID (will return empty string if none)
If UsrInfo <> "" Then 'check to see if a DOORS session is open and user logged in
LoginStatus = 1 'It is, so set status and exit
GoTo NormExit
Else ' No session open, so
With UserPWForm
.ReconMode = Reconnect
.Show ' display a user form for entering DOORS login credentials
End With
End If
' Wait in a loop until the form is closed
Do
PWStatus = UserPWForm.PWFormStat ' Get form status and loop until it changes from 0
Loop While (PWStatus = 0)
If PWStatus = -2 Then 'Cancel button was pressed
LoginStatus = -2
Unload UserPWForm
GoTo NormExit
ElseIf PWStatus = 1 Then 'Login Button was pressed
SendStr = UserPWForm.UserID & "{TAB}" & UserPWForm.UserPW & "{ENTER}" ' Get the info from the dialog box before we unload it
Unload UserPWForm ' Close the user dialog and unload it to remove the focus from it
Set m_doorsAppObj = GetObject("", APP_ID) ' Open a DOORS instance and
' set the module-level variable to point to the DOORS application
If m_doorsAppObj.result = "OK" Then ' If it opens successfully, it should return "OK"
AppActivate "DOORS" ' Set the window focus to the just-opened DOORS app
SendKeys SendStr, True 'Send the user credentials to the DOORS login window
DoEvents 'Allow for SendKeys to complete
If m_doorsAppObj.result = "OK" Then
m_DDI_Status = 0 ' DDI interface OK
If DOORS_UserID() <> "" Then
LoginStatus = 1 ' Successful login
Else
m_DDI_Status = 100
LoginStatus = -3 ' login failed - user entered incorrect credentials
End If
Else
m_DDI_Status = 100
LoginStatus = 0 ' login failed
End If
Else
m_DDI_Status = 100
LoginStatus = 0
End If
AppActivate ("EXCEL")
GoTo NormExit
ElseIf PWStatus = 2 Then 'User pressed the Reconnect button
Set m_doorsAppObj = GetObject("", APP_ID) ' connect to the DOORS instance
UsrInfo = DOORS_UserID()
LoginStatus = 1
GoTo NormExit
End If
As soon as the GetObject method executes, we get two instances of DOORS open and both of them are presenting login credential dialog boxes. Normally, our code would have sent the credentials to the open dialog box with the SendKeys method, but with two application instances open, this will not work.
I've tried using CreateObect instead, but that causes the same behavior to occur.
I'm assuming this has something to do with the .NET framework update that was recently applied enterprise-wide, because this new behavior started to appear on each PC that had been updated.
I am looking for any suggestions on workarounds or perhaps, if I'm doing something wrong, I'm open to suggestions on how to fix it.