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

multiple screen but the same detail capture

Status
Not open for further replies.

sundar766

Technical User
Feb 6, 2008
9
HI!
I have the below code from screen to excel from vt session copy
but i need it the requirment below:
i have screen K1,K2,K3,K4,K5,K6,K7,K8,K9,KA,KB,KC,KD,KE
FROM EACH SCREEN IT WILL GO USING SHIFT + KEY ENTER K2, K3
AND SO ON AND CHECK THE BELOW ON sess.Screen.SENDKEYS("<Home>GD<Tab>*<EraseEOF><Tab>NKMUT<Enter>")
WRTIE INTO EXCEL .
MY QUESTION IS HOW DO I PUT THE ABOVE ONE IN ARRAY? COULD YOU PROVIDE HOW CAN I DO THIS ONE
SO THAT I WILL CHECK EACH SCREEN THE BELOW ONE CHECK AND WRITE INTO EXCEL.
COULD YOU PROVIDE THE CODE IN THE ABOVE THING
THNKS A LOT FOR YOUR HELP.


Declare Sub Wait(Sess As Object)

Sub Main()
Dim Sys As Object, Sess As Object

Set Sys = CreateObject("Extra.System")

If Sys Is Nothing Then
MsgBox ("Could not create Extra.System...is E!PC installed on this machine?")

Exit Sub
End If

Set Sess = Sys.ActiveSession

If Sess Is Nothing Then
MsgBox ("No session available...stopping macro playback.")
Exit Sub
End If

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''



Sess.Screen.SENDKEYS("<Home>GD<Tab>*<EraseEOF><Tab>NKMUT<Enter>")


Dim xl As Object, xl_wb As Object, xl_sheet_1 As Object, file_name As String
Dim vEHNO As String, vEHNAME As String
Dim Effdate As String, PARTNUMBER As String, PARTNAME As String
Dim Stat As String, Errors As String, LastUpdate As String
Dim i As Integer, j As Long
Dim dict As Object
Dim sFile as String

file_name = "C:\Documents and Settings\Desktop\VEH.xls"

sFile = "C:\Documents and Settings\Desktop\VEH.XLS"

Set xl = CreateObject("Excel.Application")
' Set xl_wb = xl.Workbooks.Open(file_name)
Set xl_wb = xl.Workbooks.Add

xl_wb.SaveAs(sFile)
Set xl_sheet_1 = xl_wb.Sheets("Sheet1")


xl.Visible = True
xl.DisplayAlerts = False


xl_sheet_1.Range("A:A").EntireRow.Font.Size = 11

xl_sheet_1.Columns("A").ColumnWidth = 5
xl_sheet_1.Columns("B").ColumnWidth = 12
xl_sheet_1.Columns("C").ColumnWidth = 10
xl_sheet_1.Columns("D").ColumnWidth = 5
xl_sheet_1.Columns("E").ColumnWidth = 4
 
sorry! earlier it is half of the code only. here it is full code
Declare Sub Wait(Sess As Object)

Sub Main()
Dim Sys As Object, Sess As Object

Set Sys = CreateObject("Extra.System")

If Sys Is Nothing Then
MsgBox ("Could not create Extra.System...is E!PC installed on this machine?")

Exit Sub
End If

Set Sess = Sys.ActiveSession

If Sess Is Nothing Then
MsgBox ("No session available...stopping macro playback.")
Exit Sub
End If

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''



Sess.Screen.SENDKEYS("<Home>GD<Tab>*<EraseEOF><Tab>NKMUT<Enter>")


Dim xl As Object, xl_wb As Object, xl_sheet_1 As Object, file_name As String
Dim vEHNO As String, vEHNAME As String
Dim Effdate As String, PARTNUMBER As String, PARTNAME As String
Dim Stat As String, Errors As String, LastUpdate As String
Dim i As Integer, j As Long
Dim dict As Object
Dim sFile as String

file_name = "C:\Documents and Settings\Desktop\VEH.xls"

sFile = "C:\Documents and Settings\Desktop\VEH.XLS"

Set xl = CreateObject("Excel.Application")
' Set xl_wb = xl.Workbooks.Open(file_name)
Set xl_wb = xl.Workbooks.Add

xl_wb.SaveAs(sFile)
Set xl_sheet_1 = xl_wb.Sheets("Sheet1")
xl.Visible = True
xl.DisplayAlerts = False
xl_sheet_1.Range("A:A").EntireRow.Font.Size = 11
xl_sheet_1.Columns("A").ColumnWidth = 5
xl_sheet_1.Columns("B").ColumnWidth = 12
xl_sheet_1.Columns("C").ColumnWidth = 10
xl_sheet_1.Columns("D").ColumnWidth = 5
xl_sheet_1.Columns("E").ColumnWidth = 4
xl_sheet_1.Columns("F").ColumnWidth = 5
xl_sheet_1.Columns("G").ColumnWidth = 7
xl_sheet_1.Columns("H").ColumnWidth = 18
xl_sheet_1.Cells(1,1)= "VEH"
xl_sheet_1.cells(1,2)= "VEHNAME"
xl_sheet_1.Cells(1,3)= "EFFDATE"
xl_sheet_1.Cells(1,4)= "PARTNAUMBER"
xl_sheet_1.Cells(1,5)= "PARTNUMBER"
xl_sheet_1.cells(1,6)= "STAT"
xl_sheet_1.Cells(1,7)= "ERRORS"
xl_sheet_1.Cells(1,8)= "LAST UPDATE"

j = 2

Do While True

for i = 06 to 21
VEH = Trim(Sess.Screen.GetString(i, 09, 5))
VEHNAME = Trim(Sess.Screen.GetString(i, 16, 10))

Effdate = Trim(Sess.Screen.GetString(i, 28, 8))

PARTNUMBER = Trim(Sess.Screen.GetString(i, 38, 5))
PARTNAME = Trim(Sess.Screen.GetString(i, 45, 3))
Stat = Trim(Sess.Screen.GetString(i, 50, 1))
Errors = Trim(Sess.Screen.GetString(i, 54, 7))
LastUpdate = Trim(Sess.Screen.GetString(i, 63, 17))

xl_sheet_1.Cells(j, "A").Value = VEH
xl_sheet_1.Cells(j, "B").Value = VEHNAME
xl_sheet_1.Cells(j, "C").Value = Effdate
xl_sheet_1.Cells(j, "D").Value = """&PARTNUMBER
xl_sheet_1.Cells(j, "E").Value = STAT
xl_sheet_1.Cells(j, "F").Value = Stat
xl_sheet_1.Cells(j, "G").Value = Errors
xl_sheet_1.Cells(j, "H").Value = Lastpdate


j = j + 1

Next

If UCase(Sess.Screen.GetString(22, 008, 11)) = "END OF LIST" Then
Sess.Screen.SendKeys ("<ENTER>")
Sess.Screen.SendKeys.SendWait("<SHIFT>+<TAB>")

Exit Do
Else

Sess.Screen.SendKeys ("<ENTER>")
'Sess.Screen.SendKeys("<TAB>")
Call Wait(Sess)

End If
Loop

xl_wb.Save

xl_wb.Close
xl.Quit

Set x1_sheet_2 = Nothing
Set xl_sheet_1 = Nothing
Set xl_wb = Nothing
Set xl = Nothing
Set Sess = Nothing
Set Sys = Nothing
End Sub



Sub Wait(Sess As Object)
Do While Sess.Screen.OIA.Xstatus <> 0
DoEvents
Loop
End Sub






 
If you need to input K1, K2, K3, etc. This shows how you'd setup the array and how you'd enumerate through it.

Code:
Dim aScreens(13) As String
Dim sScreen As String
Dim iScreen As Integer
aScreens(0) = "K1"
aScreens(1) = "K2"
aScreens(2) = "K3"
aScreens(3) = "K4"
aScreens(4) = "K5"
aScreens(5) = "K6"
aScreens(6) = "K7"
aScreens(7) = "K8"
aScreens(8) = "K9"
aScreens(9) = "KA"
aScreens(10) = "KB"
aScreens(11) = "KC"
aScreens(12) = "KD"
aScreens(13) = "KE"

For iScreen = 0 To UBound(aScreens)
  sScreen = aScreens(iScreen)
  Sess.Screen.SendKeys sScreen
Next
 
Thank you skie. But each screen it will go through the
the below process, and it will write into excel
so coudl you provide the code where do i have to modify in my code. thanks a lot.
Sess.Screen.SENDKEYS("<Home>GD<Tab>*<EraseEOF><Tab>NKMUT<Enter>")

 
I'm having weird problems with posting a reply... So I'm going to try splitting this over a few posts.

I'm taking a stab in the dark as to where you need it to loop through the array.
Code:
Sub Main()
'Extra Objects
  Dim Sys As Object
  Dim Sess As Object
  Dim Scr As Object

'Excel Objects
  Dim xl As Object
  Dim xl_wb As Object
  Dim xl_sheet_1 As Object

'String Variables
  Dim vEHNO As String
  Dim vEHNAME As String
  Dim Effdate As String
  Dim PARTNUMBER As String
  Dim PARTNAME As String
  Dim Stat As String
  Dim Errors As String
  Dim LastUpdate As String  
  Dim sFile As String
  Dim aScreens(13) As String

'Integer Variables
  Dim i As Integer
  Dim j As Integer
  Dim iScCnt As Integer

'Set aScreens array
  aScreens(0) = "K1"
  aScreens(1) = "K2"
  aScreens(2) = "K3"
  aScreens(3) = "K4"
  aScreens(4) = "K5"
  aScreens(5) = "K6"
  aScreens(6) = "K7"
  aScreens(7) = "K8"
  aScreens(8) = "K9"
  aScreens(9) = "KA"
  aScreens(10) = "KB"
  aScreens(11) = "KC"
  aScreens(12) = "KD"
  aScreens(13) = "KE"
 
Skie
thank you so much and i apologies for that.
sorry about that. Really iam not wounding you. i think i will repharse the question. may be you might not understand my question the way i asked you.
i have in one screen capture all datas and put it in excel
the same thing i need to do with different screen but datas may be vary. or no such found records.
each and every screen first screen go from vt session so it grab the datas and put it in excel next sned keys <BACKTAB> IT GOES DOES AND WAIT FOR STRING k2
so i did it the follwoing code
if instr(UCASE (Sess.Screen.GetString(28, 008, 2)) = "k2" Then
Sess.Screen.SENDKEYS "<Home>GD<Tab>*<EraseEOF><Tab>NKMUT<Enter>")

and do rest of the thing datas copy into excel
what i am asking the same thing i will do up to K14
THAT'SWHY I ASKED YOU CAN I PUT DO WHILE LOOP
PLEASE LET ME KNOW
please help me is it correct?



 
Do While True"
True is always True, you will loop forever. You need a condition to exit the loop.

e.x.


Do While not Done
x = x + 1
if x = 15 then Done = True
Loop

[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]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top