Smart questions
Smart answers
Smart people
Join Tek-Tips Forums
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • 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!

Join Tek-Tips
*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.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Need Putstring help as paste doesn't work coping activecell.

link99sbc (TechnicalUser) (OP)
11 Apr 09 0:42
' Global variable declarations
Global g_HostSettleTime%
Global g_szPassword$

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 = 300        ' 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

        Dim Sys As Object, Sess As Object, MyScreen As Object, MyArea As Object

    Set Sys = CreateObject("EXTRA.System")
    Set Sess = Sys.ActiveSession
    Set MyScreen = Sess.Screen

 'Activates the Spreedsheet which is already open        
        AppActivate "Microsoft Excel - SCOP stats.xls"

'Copies the active cell and moves down to the next cell which makes it the next active cell.
'I do this more than a 1000 times.  "Column with over 1000 names"
        Sendkeys "%EC{Down}"                                        
        Sess0.Screen.WaitHostQuiet(g_HostSettleTime)

'Alt tabs back to Extra Session
        Sendkeys "%{tab}"                                                 
        Sess0.Screen.WaitHostQuiet(g_HostSettleTime)

'Goes to the home position, tabs to the next variable and
'types Name and goes to the next variable (Field) by default
'since only four characters are required in the first field.
        Sess0.Screen.Sendkeys("<Home><Tab>NAME")   
        Sess0.Screen.WaitHostQuiet(g_HostSettleTime)

'Paste the copied cell from Excel in the second variable space or Field if you prefer.
        Sendkeys "%EP"                                                    
        Sess0.Screen.WaitHostQuiet(g_HostSettleTime)

'Triggers Extra Session to search a Data Base for the Name that was pasted in the second field.
        Sess0.Screen.Sendkeys("<Enter>")                       

    System.TimeoutValue = OldSystemTimeout
End Sub

This works fine in Extra Enterprise but will not paste in Extra Extreme 9.0 SP2
using "%EP" , Sess0.Screen.paste, MyScreen paste, My Area paste.  No matter how I write
it, IT WILL NOT PASTE!  Any ideas?  It will paste using the mouse or keyboard. Putstring might work but I don't know how to get the contents of the active cell and put it at 3,23 in the session.  It also needs to clear the entire line first.  3,23 to 3,70 and make the next cell down the next active cell so it will get that cell when I run the macro again. I use appactivate because the excel file is always open.
 
SkipVought (Programmer)
11 Apr 09 9:25


Quote:

'Activates the Spreedsheet which is already open        
        AppActivate "Microsoft Excel - SCOP stats.xls"

'Copies the active cell and moves down to the next cell which makes it the next active cell.
'I do this more than a 1000 times.  "Column with over 1000 names"
        Sendkeys "%EC{Down}"                                        
WHERE are you copying ANYTHING in Excel?????

Skip,
glassesDon't let the Diatribe...
talk you to death!tongue

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

link99sbc (TechnicalUser) (OP)
11 Apr 09 12:56
Wow, thanks for the fast response.
I use 4 sessions in attachmate. 3 sessions and the excel file are open but minimized in the windows toolbar.  When I use the macro with "appactivate" the excel file appears on the screen and copies the active cell then alt-tabs back to the attachmate session and pastes the contents of the active cell at 3,23 in the attachmate session.  

When I first open excel file I left click on the cell I want to start on which makes it the active cell.  So in the macro %EC{down} copyies the active cell and moves down which makes the next cell active. AtlTab returns to the Session and %EP is supposed to paste (which is the contents of the clipboard). Paste doesn't work in Attachmate Xtreme for some reason. It will paste anything from one session to another with a macro but not from excel to a session unless you use the mouse or keyboard to paste which make the macro useless. It was suggested that I use putstring but I don't know how to write it to capture the contents of the active cell, move down to make the next cell active and put it in the session at 3,23. I hope I'm making this clear. Thanks.
SkipVought (Programmer)
11 Apr 09 14:34



Then you have some asynchronous processes occurring.  How can you be ABSOLUTELY SURE that the copy occurs BEFORE your PASTE occurs in Extra???

That is no way to code, IMHO.

BTW, I do ALL my Extra coding in Excel VBA.  You get much MUCH better control of your process.

Also I never use COPY 'n' PASTE to do this kind of process.  I use PutString or the Area function to PLACE the value in the Extra screen at the proper coordinates.  I never use the Select method either.  Rather reference the cell or screen coordinates explicitly, like..

CODE

for lRow = 2 to Sheet1.UsedRange.Rows.Count
   oScrn.Area(iRow, iCol, iRow, iCol+iLen-1).value = Sheet1.cells(lrow, "A").value
   iCol=iCol +1
next


 

Skip,
glassesDon't let the Diatribe...
talk you to death!tongue

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

link99sbc (TechnicalUser) (OP)
11 Apr 09 17:16
Thanks Skip I'll give that a try.
SkipVought (Programmer)
11 Apr 09 18:12


oops.

I should have incrimeted iRow rather than iCol.

Skip,
glassesDon't let the Diatribe...
talk you to death!tongue

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

link99sbc (TechnicalUser) (OP)
14 Apr 09 12:47
I couldn't figure out how to make this work.
SkipVought (Programmer)
14 Apr 09 13:00




that nondiscript statement will not help you get a good response.

Exactly WHAT did you do?

Exactly WHAT happened?

Skip,
glassesDon't let the Diatribe...
talk you to death!tongue

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

link99sbc (TechnicalUser) (OP)
14 Apr 09 14:51
All I need is a macro in Excel to drop down 1 cell, copy the contents of that cell and put it at row 3 col 23 of my attachmate session without using paste.

Tried using you code but error said I need an Object
SkipVought (Programmer)
14 Apr 09 15:18


This is like pulling teeth! Pleeeeease provide CLEAR, CONCISE & COMPLETE information when you ask a question!

Quote:

but error said I need an Object

error on WHAT statement?

where were you running the code? in Extra or Excel?

Skip,
glassesDon't let the Diatribe...
talk you to death!tongue

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

link99sbc (TechnicalUser) (OP)
14 Apr 09 15:51
Sub Putstring()
For lrow = 2 To Sheet1.UsedRange.Rows.Count
   oScrn.Area(iRow, iCol, iRow, iCol + iLen - 1).Value = Sheet1.Cells(lrow, "A").Value
   iRow = iRow + 1
Next

End Sub

This gets a run-time error 424
Object Required
oScrn.Area(iRow, iCol, iRow, iCol + iLen - 1).Value = Sheet1.Cells(lrow, "A").Value
link99sbc (TechnicalUser) (OP)
14 Apr 09 15:55
OOH running this from Excel Macro. I would like it to know how to make this work running from attachment macro also.
SkipVought (Programmer)
14 Apr 09 21:06



How did you define and set oScrn?

Skip,
glassesDon't let the Diatribe...
talk you to death!tongue

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

link99sbc (TechnicalUser) (OP)
20 Apr 09 12:41
Solved

changed
Sendkeys "%EP"
to
Set MyArea = MyScreen.Area(3,23,3,70)
MyArea.Paste

Seems to be working ok now.

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!

Back To Forum

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