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!

Reading from a text file for a loop

Status
Not open for further replies.

crabtreejames

Technical User
Nov 13, 2006
3
US
I'm working on my first macro (largely with bits and pieces I picked up in this forum), and would appreciate any help I can get. Currently, the macro downloads information for a specific company, then exports it to a text file. I need it to loop through a list of about 500 companies, using the append format I created for the download. I created a simple account list in MS DOS Text format, but the macro opens the file with the list, but doesn't send it to the file. Here's my code:

'--------------------------------------------------------------------------------
' This macro was created by the Macro Recorder.
' Session Document: "C:\DOCUMENTS AND SETTINGS\CRABJ01\DESKTOP\SEI FILE TRANSFER SESSION.EDP"
' Date: Monday, November 13, 2006 13:28:47
' User: CrabJ01
'--------------------------------------------------------------------------------

' 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 = 3000 ' 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)
close

' This section of code contains the recorded events

Open "c:\reports\accounts.txt" for INPUT as 2
Do while not eof (2)

Sess0.Screen.Sendkeys("ta3000<Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys("********<Tab>***<Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys("admin tr<Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
' ***Need to replace this with a loop with all applicable SEI numbers***
line input #2, mystring1$
ORD$ = mid(mystring1$,1,8)

Sess0.Screen.putstring ord$,1,9 'output to the session
Sess0.Screen.Sendkeys("<enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)

' Original data, need to be using loop Sess0.Screen.Sendkeys("209899<Tab>")
Sess0.Screen.Sendkeys("10/1/06<Tab>10/31/06<Tab><Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys("<Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys("<Pf6>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys("<Tab>pc(replace)<Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys("<Enter>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys("<Pf3>")
'Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys("<Pf3>")
'Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys("<Pf3>")
'Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys("<Pf3>")
'Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.Screen.Sendkeys("<Pf3>")
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.FileTransferScheme = "Text Default"
Sess0.FileTransferScheme = "C:\Program Files\E!PC\schemes\Append Default.eis"
Sess0.FileTransferHostOS = 1
' ***Need to either make this append to the file, or create a name based on the SEI account number***
Sess0.ReceiveFile "C:\Program Files\Monarch\Reports\Volume",'clipccs.download.txt'"
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
Sess0.FileTransferHostOS = 1
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
loop

System.TimeoutValue = OldSystemTimeout
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top