×
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 a cell on an Excel sessions opened

copy a cell on an Excel sessions opened

copy a cell on an Excel sessions opened

(OP)
Hello all,

I'm new to Attachmate thank you for your understanding.

I have an excel workbook 'test' with a sheet in cell A1 and a 'test1'
I would then copy A1 test1 and paste it on my session ETRA! Sessions



Code:

'Global variable declarations
Global g_HostSettleTime%
Global g_szPassword $

Sub Main ()
'------------------------------------------------- -------------------------------
'Get the main purpose of the system
    Sun Sessions As Object
    Sun 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 timeout value timeout
    g_HostSettleTime = 3000 'milliseconds

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

'Get the necessary Session Object
    Sun 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 Then Sess0.Visible Sess0.Visible = True
    Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
    
'------------------------------------------------- -------------------------------

'Declare the Excel object
        Sun xlApp As Object, xlSheet As Object, Row As Long
        Set xlApp = CreateObject ("Excel.Application")
        xlApp.Application.DisplayAlerts = False 'disable the messages
        xlApp.Visible = True
        xlApp.Workbooks.Open Filename: = "F: \ vba \ April 04 2012.xls"
        Set xlSheet = xlApp.ActiveSheet
        Set myRange xlApp.ActiveSheet.Range = ("A2")
        Sess0.Screen.PutString xlApp.ActiveSheet.Range ("A2"). Value, Row, Col
        Sess0.Screen.SendKeys ("<Enter>")

End Sub


Thank you for all answers

 

RE: copy a cell on an Excel sessions opened


hi,

CODE

        Sun xlApp As Object, xlSheet As Object, Row As Long
        Set xlApp = CreateObject ("Excel.Application")
        xlApp.Application.DisplayAlerts = False 'disable the messages
        xlApp.Visible = True
        xlApp.Workbooks.Open Filename: = "F: \ vba \ April 04 2012.xls"
        Set xlSheet = xlApp.ActiveSheet
        Set myRange = xlSheet.Range("A2")
        Sess0.Screen.PutString myRange. Value
, Row, Col
        Sess0.Screen.SendKeys ("<Enter>")
ALSO, I would recommend that you EXPLICITLY reference the Sheet byname, rather than ActiveSheet, cuz, what if the workbook is saved with some OTHER sheet active???

CODE


        Set xlSheet = xlApp.Sheets("YourSheetName")

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