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!

Help with Getstring from changing cursor position from Attachmate 1

Status
Not open for further replies.

easygo

Technical User
Jul 6, 2011
6
CA
Hi
Hope someone can help me. I am not a programmer, just trying to write a simple macro by reading your post. My macro is in Excel VBA.I have a list of account numbers in column A. My macro should copy the ac# from Excel to Extra and bring up client info on Extra screen, then copy some info from Extra screen wherever the cursor is on Extra. The issue is the cursor position on Extra is not same always.
here is my code

Sub Main()
Dim Sessions As Object
Dim System As Object
Dim myScreen As Object
Dim myArea As Object

Set System = CreateObject("EXTRA.System")
Set Sessions = System.Sessions
Set Sess0= System.ActiveSession
Set myScreen = Sess0.Screen

g_HostSettleTime = 300

currentRow = myScreen.Row
current.Col = myScreen.Col

Set myArea = myScreen.Area(currentRow, currentCol, currentRow, currentCol + 12)

Do
Sess0.Screen.PutString(ActiveCell.Value), 22, 16
Sess0.Screen.SendKeys ("<Enter>") 'the cursor is at 22,07 at this point
sess0>Screen.WaitHostQuiet (g_HostSettleTime)
Sess0.Screen.SendKeys ("<Pf3>") 'at this point the cursor position is either 10,03 or 14,03 or 18,03 or 22,07
Sess0.Screen.WaitHostQuiet (g_HostSettleTime) 'my codes runs ok upto this point.
ActiveCell.offset(0,1)= myArea 'i am stuck here, no matter where the cursor is in Extra, it copies the area 26,07,26,07+12)

ActiveCell.offset(1,0).Select
Loop Until IsEmpty(ActiveCell)

End Sub

what am I doinh wrong? please help.
 
try placing the literal "Do" right after this statement "g_HostSettleTime = 300"
 
Thanks a lot for the response. I made the change as you suggested and see some improvement. However it is not consistent. The cursor position is copied correctly only sometimes. Other times it copies as initially it was doing. What could be the issue? Please assist.
 
did you correct this:

current.Col = myScreen.Col

it should be currentCol = myScreen.Col
 
Yes. I caught that error and already correted it. Still same issue. Not consistence. Thanks again. Plead help me.
 
each time you enter PF3, you need to find the coordinates, something like this
Code:
Do 
Sess0.Screen.PutString(ActiveCell.Value), 22, 16
Sess0.Screen.SendKeys ("<Enter>") 
'the cursor is at 22,07 at this point
sess0.Screen.WaitHostQuiet (g_HostSettleTime)

Sess0.Screen.SendKeys ("<Pf3>") 
'at this point the cursor position is either 10,03 or 14,03 or 18,03 or 22,07

Sess0.Screen.WaitHostQuiet (g_HostSettleTime) 
'my codes runs ok upto this point.
[blue]
currentRow = myScreen.Row
currentCol = myScreen.Col
Set myArea = myScreen.Area(currentRow, currentCol, currentRow, currentCol + 12)[/blue]

ActiveCell.offset(0,1)= myArea 
'i am stuck here, no matter where the cursor is in Extra, it copies the area 26,07,26,07+12)

ActiveCell.offset(1,0).Select

Loop Until IsEmpty(ActiveCell)


 



Whether it is Excel or Extra, I AVOID using a selected location.

If you get in the habbit of programming so that you have a row & column reference for EVERYTHING that you are doing, the cursor location or active cell is nearly always totally irrlelvant!

That makes GetString or PutString very simple!

Skip,
[sub]
[glasses]Just traded in my old subtlety...
for a NUANCE![tongue][/sub]
 
Fantastic. The codes are working great now. You're the best.
Thanks for the additional tip too, I got it.
Have a great weekend.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top