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

How to copy values from excel for different screens

Status
Not open for further replies.

nal123sri

Technical User
May 13, 2007
2
US
Hi

I have to create account through different screens. I need to feed different data from the excel sheet to be capture by extra and go to the next screen. In the mean time I need some fields to be caputred from extra and put it in a different excel sheet. Also I have to capure each screen and paste in word document.

a new word document shoud be opened for each account.

can i save the word document using variable and putting them in a loop?

for example

I have 5 screen for 1 account

I have to open an excel workbook name account.xls

from account.xls the row 1 column 1 should go to screen 1 in extra
from account.xls the row 1 column 2 should go to screen 2 and so on.

at the same time value from screen 1 should be copied to account.xls sheet 2

the screen1 of extra should be copied to a word document screen1.doc
The screen 2-screen 5 should be appended to the same word document.

for account 2 the data should be taken from account.xls row 2 of the same columns and the word document should be screen2.doc.

can anyone help me in this regard.

Thanks

 
Here's something for you to play with.

Code:
Declare Sub Wait()

GLOBAL Sys as Object
GLOBAL Sess as Object

Sub Main()
   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

   ' ########################################################################

   Dim xl_app As Object, xl_wb As Object, curr_cell As String, xl_file As String
   Dim word_app As Object, word_doc As Object, word_file As String
   Dim i As Integer, j As Integer, iRows As Long, iCols As Long, curr_line As String

   xl_file = "C:\Documents and Settings\All Users\Documents\Attachmate\Macros\Input\Accounts.xls"
   
   Set xl_app = CreateObject("Excel.Application")
   Set xl_wb = xl_app.Workbooks.Open(xl_file)

   iRows = Sess.Screen.Rows
   iCols = Sess.Screen.Cols

   For i = 1 To xl_wb.Sheets(1).UsedRange.Rows.Count
      ' xl_wb.Sheets(1).Cells(1, 1)   <- Excel Sheet 1, Row 1, Col 1
      ' xl_wb.Sheets(1).Cells(1, 2)   <- Excel Sheet 1, Row 1, Col 2
      ' xl_wb.Sheets(2).Cells(1, 2)   <- Excel Sheet 2, Row 1, Col 1

      curr_cell = xl_wb.Sheets(1).Cells(i, 1)

      Sess.Screen.PutString curr_cell, 4, 5   ' A_STRING, ROW 4, COL 5
      
      'Sess.Screen.SendKeys ("<Enter>")
      'Wait

      xl_wb.Sheets(2).Cells(i, 1) = curr_cell

      ' #################################
      ' SCRAPE SCREEN CONTENTS TO MS WORD
      ' #################################
      
      Set word_app = CreateObject("Word.Application")
      Set word_doc = word_app.Documents.Add

      'word_app.Visible = True
      word_file = "C:\Documents and Settings\WinblowsME\Desktop\Temp\Screen" & i & ".doc"
            
      For j = 1 To iRows
         curr_line = Sess.Screen.GetString(j, 1, iCols)
         word_app.Selection.TypeText curr_line & Chr(13)
      Next j

      word_doc.SaveAs (word_file)
      word_app.Quit
      
      Set word_doc = Nothing
      Set word_app = Nothing      
   Next i

   xl_wb.Save
   xl_app.Quit

   Set xl_wb = Nothing
   Set xl_app = Nothing
End Sub

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

we use the enter key ro navigate across screens.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top