×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

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!

*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

Copy and Append Loop Macro

Copy and Append Loop Macro

Copy and Append Loop Macro

(OP)
Hi guys I am trying to get a simple Copy and Append Loop going from the Attachmate Extra! screen. Basically there is a report I want to get to txt or excel format. The report is usually around 50000 lines or more.

I recorded the below keystrokes but not sure how to make it loop to the end of the report.

||||||||||||||||||||||||||||||||||||||||||||||||||||||||


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 = 3000        ' 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.CopyAppend    
    Sess0.Screen.Sendkeys("<Pf8>")    
    Sess0.Screen.WaitHostQuiet(g_HostSettleTime)

    System.TimeoutValue = OldSystemTimeout
End Sub
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||


Any help would be greatly appreciated!  

RE: Copy and Append Loop Macro


hi,

Put this code in a loop

CODE

' This section of code contains the recorded events
    Sess0.Screen.CopyAppend    
    Sess0.Screen.Sendkeys("<Pf8>")    
    Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
You must test your messages after each screen is painted, so if the message in row 24 is CONTINUE then...

CODE

' This section of code contains the recorded events
do while Trim(Sess0.Screen.GetString(24,1,80)) = "CONTINUE"
    Sess0.Screen.CopyAppend 'don't see this method in Attachmate   
    Sess0.Screen.Copy
'BTW, I almost NEVER use Extra BASIC -- YUK!
'I use Excel VBA, much more versatile!!!
    with xl.YourWorkbookObject.YourSheetObject
       .cells(.[A1].currentregion.rows.count+1,1).paste
    end with

    Sess0.Screen.Sendkeys("<Pf8>")    
    Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
    Do Until Sess0.Screen.WaitForCursor(1, 1) 'or wherever your cursor rests after <PF8>          
       DoEvents
    Loop
loop
 

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

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