Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run macro in Active Session

Status
Not open for further replies.

wozza261

Programmer
Oct 24, 2011
3
0
0
AU
This question is similar to others in the forum, but none seem answer the obvious. If I have sessions ABC1 and ABC2, the last one opened ABC2 is always the active one.

If I run the following macro from ABC1 it only runs in ABC2 !

How do I get macro to run from the session where I use Tools/Macro/Run ?

I would have thought this code line would set it all up correctly ?

Set Sess0 = System.ActiveSession

'--------------------------------------------------------------------------------
' This macro was created by the Macro Recorder.
'--------------------------------------------------------------------------------

' Global variable declarations
Global g_HostSettleTime%

Sub Main()
'--------------------------------------------------------------------------------
' Get the main system object
Dim Sessions As Object
Dim System As Object
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 Sessions = System.Sessions

If (Sessions is Nothing) Then
Msgbox "Could not create the Sessions collection object. Stopping macro playback."
STOP
End If
'--------------------------------------------------------------------------------
' Set the default wait timeout value
g_HostSettleTime = 1000 ' milliseconds

OldSystemTimeout& = System.TimeoutValue
If (g_HostSettleTime > OldSystemTimeout) Then
System.TimeoutValue = g_HostSettleTime
End If

' Get the necessary Session Object
Dim Sess0 As Object
Set Sess0 = System.ActiveSession
If (Sess0 is Nothing) Then
Msgbox "Could not create the Session object. Stopping macro playback."
STOP
End If
If Not Sess0.Visible Then Sess0.Visible = TRUE
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)

' This section of code contains the recorded events
Sess0.Screen.Sendkeys("<Clear>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys("ZOLDR DI L *<Enter>")

System.TimeoutValue = OldSystemTimeout
End Sub

 



hi,

Check out my code in thread1-1651787

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Actually I think the solution to this is the old "Have you tried switching it on and off ?"
While trying to figure this out, I found the following thread as well.


It seems that sometimetimes the following does not work:
Set Sess0 = System.ActiveSession
And the only solution is to shut down all sessions and reboot.

Another way to test if you need a reboot is to start the offending session and see if you can run any macro. If you get the "Could not create the Session object. Stopping macro playback." then try a reboot.
Then start each session and run a macro before starting the next session. This will make sure System.ActiveSession is working.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top