I'm running this in excel. I can't seem to figure out what is wrong. I get a debug message at this line of code
Code:
For x = 2 To Worksheet.UsedRange.Rows.Count
Code:
Sub Main()
Dim Sessions, System As Object, Sess0 As Object
Set System = CreateObject("EXTRA.System")
Set Sessions = System.Sessions
Set Sess0 = System.ActiveSession
file = "H:\Macros - Reports\FC Refferals Macros\120 Macro\120 Macro (4)\120 Macro Input 4.xls"
Dim obj As Object
Dim objWorkbook As Object
Set obj = CreateObject("Excel.Application")
obj.Visible = True
obj.Workbooks.Open file
'Do loop starting at row 2 and ending at Worksheet.UsedRange.Rows.Count
'which is end of all rows in sheet.
For x = 2 To Worksheet.UsedRange.Rows.Count
'Set account number = to row (row x, column 1), where x = 2 for the first loop and going
'all the way to the end of the count of rows, so on the second loop, x would be 3, so
'it would read the account from row 3, column 1. It starts at 2 because it assumes there
'is a header row on the worksheet, you can change it in the above for statement
str_act_num = Worksheet.Cells(x, 1)
'moves cursor to location 7,30
Sess0.Screen.MoveTo 7, 30
'send acct num string and erases end and enters
Sess0.Screen.SendKeys ("x")
Sess0.Screen.MoveTo 10, 21
Sess0.Screen.SendKeys (str_act_num & "<EraseEOF><Enter>")
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
If Sess0.Screen.GetString(23, 2, 17) = "ACCOUNT NOT FOUND" Then
str_status = "ACCOUNT NOT FOUND"
Else
str_status = "ACCOUNT FOUND"
str_reason = Sess0.Screen.GetString(21, 26, 8)
Worksheet.Cells(x, 4) = str_reason
str_reason = Sess0.Screen.GetString(21, 44, 1)
Worksheet.Cells(x, 2) = str_reason
str_reason = Sess0.Screen.GetString(4, 16, 8)
Worksheet.Cells(x, 5) = str_reason
str_reason = Sess0.Screen.GetString(12, 55, 13)
Worksheet.Cells(x, 6) = str_reason
str_reason = Sess0.Screen.GetString(12, 14, 3)
Worksheet.Cells(x, 7) = str_reason
Sess0.Screen.SendKeys ("<pf3>")
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
End If
Worksheet.Cells(x, 3) = str_status
Next
MsgBox "Macro Done"
End Sub