SuperKoopa
Technical User
Hello,
I have yet another question for a different situation. I would like to create a button in excel that opens an an Attachmate Session and then sendkeys, however, if a session is already open I would like it just to bring that existing Attachmate session forward as the active window. Right now I am using the code below to open a session and perform the sendkeys, but I have no idea how to add coding for an existing attachmate to be recognized. So as you can imagine if the button I've created using the code below is clicked and there is an existing attachmate open, it screws it up. Any assistance I would absolutely appreciate! Thank you!
---------------------------------------------------------------------------------
Sub OpenLSP()
Set System = CreateObject("EXTRA.System") ' Gets the system object
If (System Is Nothing) Then
MsgBox "Could not create the EXTRA System object. Stopping macro playback."
Stop
End If
Set session = System.Sessions.Open("C:\Program Files\Attachmate\EXTRA!\Sessions\Morgan.EDP")
If (session Is Nothing) Then
MsgBox "Could not create the Sessions collection object. Stopping macro playback."
Stop
End If
g_HostSettleTime = 300 ' milliseconds
OldSystemTimeout& = System.TimeoutValue
If (g_HostSettleTime > OldSystemTimeout) Then
System.TimeoutValue = g_HostSettleTime
End If
If Not session.Visible Then session.Visible = True
session.Screen.waithostquiet (g_HostSettleTime)
Dim Sess0 As Object
Set Sess0 = System.ActiveSession
session.Screen.waithostquiet (g_HostSettleTime)
Do
session.Screen.waithostquiet (g_HostSettleTime)
Sess0.Screen.SendKeys ("X LSP<Enter>")
session.Screen.waithostquiet (g_HostSettleTime)
Loop Until Sess0.Screen.GetString(1, 29, 6) = "Signon"
session.Screen.waithostquiet (g_HostSettleTime)
End Sub
I have yet another question for a different situation. I would like to create a button in excel that opens an an Attachmate Session and then sendkeys, however, if a session is already open I would like it just to bring that existing Attachmate session forward as the active window. Right now I am using the code below to open a session and perform the sendkeys, but I have no idea how to add coding for an existing attachmate to be recognized. So as you can imagine if the button I've created using the code below is clicked and there is an existing attachmate open, it screws it up. Any assistance I would absolutely appreciate! Thank you!
---------------------------------------------------------------------------------
Sub OpenLSP()
Set System = CreateObject("EXTRA.System") ' Gets the system object
If (System Is Nothing) Then
MsgBox "Could not create the EXTRA System object. Stopping macro playback."
Stop
End If
Set session = System.Sessions.Open("C:\Program Files\Attachmate\EXTRA!\Sessions\Morgan.EDP")
If (session Is Nothing) Then
MsgBox "Could not create the Sessions collection object. Stopping macro playback."
Stop
End If
g_HostSettleTime = 300 ' milliseconds
OldSystemTimeout& = System.TimeoutValue
If (g_HostSettleTime > OldSystemTimeout) Then
System.TimeoutValue = g_HostSettleTime
End If
If Not session.Visible Then session.Visible = True
session.Screen.waithostquiet (g_HostSettleTime)
Dim Sess0 As Object
Set Sess0 = System.ActiveSession
session.Screen.waithostquiet (g_HostSettleTime)
Do
session.Screen.waithostquiet (g_HostSettleTime)
Sess0.Screen.SendKeys ("X LSP<Enter>")
session.Screen.waithostquiet (g_HostSettleTime)
Loop Until Sess0.Screen.GetString(1, 29, 6) = "Signon"
session.Screen.waithostquiet (g_HostSettleTime)
End Sub