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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

copy a cell on an Excel sessions opened

Status
Not open for further replies.

lestatjt

Technical User
Apr 4, 2012
8
FR
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

 

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[b]
        Set myRange = xlSheet.Range("A2")
        Sess0.Screen.PutString myRange. Value[/b], 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.[b]Sheets("YourSheetName")[/b]

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top