×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Run macro in Active Session

Run macro in Active Session

Run macro in Active Session

(OP)
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

RE: Run macro in Active Session

(OP)
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.

http://www.tek-tips.com/viewthread.cfm?qid=477787

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.   

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close