Problems using GetObject method in VBA to launch an external application

Copper Contributor

I've been using the GetObject method to launch an instance of an external application (IBM Rational DOORS) from within an Excel VBA application and it used to work properly, but recently after our IT department rolled out some new enterprise-wide updates, the code now causes two instances of the external application to be started. This causes a problem because my Excel VBA code needs to send a userid and password to the external application in order to be able to use it. After this unexpected behavior began, I also tried CreateObject instead of GetObject, but the same problem occurs. Has anyone else encountered something like this and / or have any idea what the root cause might be? 

 

A code snippet follows below:

 

Const APP_ID As String = "DOORS.Application"

 

Dim m_doorsAppObj As Object

 

... 

 

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 object instance
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")

0 Replies