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

read cointuous rows write into screen 2

Status
Not open for further replies.

buddha88

Programmer
Sep 9, 2009
13
CA
I am trying to do read from excel sheet2 column b and row 8 wrtie to the screen position in 45,52
How do identity that is in row 8 and till end
Putstring in screen do something and go back again read next row and putstring in screen till endth row
I could not figure it out. Could you please help me
 
Search this forum for 'Excel' and you'll find many examples. Put an attempt together and we'll help you work out the problems. Let us know what language you plan on writing in. If your just reading from Excel you could be okay using Extra for anything more I'd recomend using VBA.

[small]Sometimes you gotta leave your zone of safety. You have to manufacture Inspirado. You gotta get out of the apartment. You've got to run with the wolves. You've got to dive into the ocean and fight with the sharks. Or just treat yourself to a delicious hot fudge sundae........ with nuts. - Jack Black[/small]
 
vzachin
thanks for your comment. i did some point
here is part of the code
could yuo help me

last_row2 = xl_sheet_2.Range("B2").CurrentRegion.Rows.Count

next_row = xl_sheet_2.Range("B2").CurrentRegion.Rows.Count + 1

For k = 2 To last_row2
x = Trim(xl_sheet_2.range("Bk") ' syntax error

MyScreen.PutString x,8,13

Next

 
buddha88,

in order for us to help you, you need to provide more details...

IknowMe said:
Let us know what language you plan on writing in
...

are you writing this in excel or attachmate?

in your latest post
Code:
 x = Trim(xl_sheet_2.range("Bk")  ' syntax error
what is .range("Bk") ? is that column BK? if that is, then you need a row to go with that...

did you at least try the code i posted?
 
vzchin
thanks this is my code here:
after this
MyScreen.PutString ("SM"),6,48
after press enter
after that sercH 'MARKED"- YES"
write into column f and go back to next row in column b and
repeat do---- loop
i am struggling here becasue the marked is not in first page
it come in 4th page or some where in middle i could not write in column f
could you help me in this regards
thanks guys really great!
the below code shows: here

j = 2
Last_row2 = xl_sheet_2.Range("B1").CurrentRegion.Rows.Count
msgbox(last_row2)
' next_row = xl_sheet_2.Range("B1").CurrentRegion.Rows.Count + 1
'msgbox(next_row)
For k = 2 To last_row2

do
x = Trim(xl_sheet_2.Cells(k, "B").Value)


MyScreen.PutString x, 5,27

MyScreen.SENDKEYS("<Enter>")
iwait
MyScreen.PutString ("SM"),6,48
MyScreen.SENDKEYS("<Enter>")

IF MyScreen.find ("MARKED:") then
DONT KNOW WHAT I HAVE WRITTEN HERE
end if

Loop Until xl_sheet_2.Cells(k, "B").Value <> ""
Next

end with
 
you still didn't say if you are using Extra basic or Excel VBA.

try this code out

Code:
Sub Main()
Dim Sys As Object, Sess As Object, MyScreen As Object, MyArea As Object
Set Sys = CreateObject("EXTRA.System")
Set Sess = Sys.ActiveSession
Dim obj as object
Dim objWorkbook as object
Set obj=CreateObject("Excel.Application")

Set obj = Getobject("C:\test.xls")    'i used this to test the code   
set objWorkbook=obj.Worksheets("bud")   'with this worksheet


For i = 2 To obj.ActiveSheet.Rows.Count  
xlData = trim(objWorkBook.Range("B" & i))      

if xlData = "" Then exit For

	Set MyScreen = Sess.Screen
        MyScreen.PutString xlData,5,27  'this places the data from Excel
        MyScreen.SendKeys ("<Enter>")
        'consider pausing here to give a chance for system response
        MyScreen.WaitHostQuiet (100)
        MyScreen.PutString "SM", 6,48  'your code had ("SM"), this is wrong

        MyScreen.SendKeys ("<Enter>")
        'consider pausing here to give a chance for system response
        MyScreen.WaitHostQuiet (100)
        
        'the following code below 
        'moves the cursor to row 1 column one
        'and then searches for the word MARKED
        'if the word is found, the cursor is moved to 
        'where the word MARKED was found
        'a comparison is made where the cursor is found
        'if the cursor is still on row 
        'if it's not found, then go to next page
        'and continue until the word is found
        
        Do
         
	MyScreen.MoveTo 1, 1

	Set MyArea = MyScreen.Search("MARKED")
        MyScreen.MoveTo MyArea.Bottom, MyArea.Left
        MyRw = MyScreen.Row

        If MyRw = 1 Then
        MyScreen.SendKeys ("<Enter>")  'dunno how you go to next page    
                                        'change accordingly
        Else
        'this means MARKED was found because the cursor was moved 
        'from 1,1
        'the following will place the word "YES" 
        'in column F same row as B
        objWorkBook.Range("F" & i) = "YES"
        
        exit do  'this will now loop to next entry in Excel Sheet Col B
        end if
        
        Loop  
        'CAUTION:
        'need to exit Loop if MARKED is not found
        'how many pages are there? or will MARKED always be found?
        'if there are only 6 pages, then add a counter for each loop
        
        
next i	
 
End Sub

hth
 
vschin
thanks a lot, i will try it on monday and let you know
but there is no page limit may be 2nd page or may 4 or 6.
so can i do untill if Myscreen, search (""marked: ") then
What is this code for if it is not found in first page market instead of enter f8 go to next page
MyScreen.MoveTo MyArea.Bottom, MyArea.Left
MyRw = MyScreen.Row

If MyRw = 1 Then 'why this is 1,
thanks a lot, learnt from you, great!!. thanks a lot .
one more is it possible can i generate standard email .
i am writing macro in Extra!.
standard email with different user



 
but there is no page limit
i find this rather hard to believe. what will happen if "marked: " is not found? will you page advance until infinity and beyond? that would be programming suicide. you need to think this over carefully...

If MyRw = 1 Then 'why this is 1

if you look carefully at the code, i added this right after Do
Code:
MyScreen.MoveTo 1, 1
this means move the cursor to row 1, column 1.
then it proceeds to "search" for your qualifier "marked". if it finds this qualifier, move the cursor to the where the word marked begins
Code:
MyScreen.MoveTo MyArea.Bottom, MyArea.Left
. my assumption is that it won't be on row 1. i added
Code:
MyRw = MyScreen.Row
to show where the row is after the search. so if MyRw = 1 (remember i moved the cursor to row 1 when i first started) that means "marked" was not found. otherwise it would be in another row, (unless it can be on row 1, then we can adjust to code to also look at the column). if MyRw = 1,that means you need to go to the next page and continue searching (this is where you need to place your code to page advance. i don't know what your page advance key is so i put in <enter>if it is P8, then code it accordingly). then again, it moves the cursor back to row 1, column 1. this will continue until the search is successful. if the search is successful, that's where the ELSE statement is used. if it's successful, then write the data back to Excel. My assumption was you wanted the literal "YES" written back to Excel and that's what i provided.

you need to step through the code and figure out on your own what the code is doing or not doing. this is the *best* way to learn.

and sorry, i don't know how to handle email. maybe someone else can help you with that in your other post
 
thank you so much vzchin. i understood fully what you said explain in detailed. thanks a lot. i will step through the code.
 
buddha88 said:
it works great!!! thanks for your [red]valuable[/red] hint

You really ought to...
[blue]
Thank vzachin
for this [red]valuable[/red] post!
[/blue].

The [purple]little purple Stars[/purple] accomplish several important things.

First, it gives positive feedback to contributors, that their posts have been helpful.

Second, it identifies threads as containing helpful posts, so that other members can benefit.

And third, it identifies the original poster (that's YOU, BTW), as a grateful member, that not only receives, but is willing to give tokens of thanks.

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