crabtreejames
Technical User
Through trial and error, combined with stealing every tidbit I could from this site, I've finally convinced Attachmate to read data from Excel. The downside to this pilfered knowledge is that I don't understand how to apply it to my actual needs. Specifically, how can I expand on what I have in order to import the data from column B? Specifically, the macro runs the same report multiple times and stores the results for downloading, but I want to be able to run reports that call for more than just the account number. What line(s) would I need to add to pull column B's data?
Here's my code:
Sub Main
Dim appExcel As Object
Dim wbExcel As Object
Dim aSheet As Object
Dim Sessions as Object
Dim System as Object
Dim AccountNum As String
Dim Sess0 as Object
Set System = CreateObject("EXTRA.System")
Set Sessions = System.Sessions
Set Sess0 = System.ActiveSession
If (Sessions is Nothing) Then
Msgbox "Could not create the Sessions collection object. Stopping macro playback."
STOP
End If
Set AppExcel = CreateObject("Excel.Application")
If (System is Nothing) Then
Msgbox "Could not create the EXTRA System object. Stopping macro playback."
STOP
End If
Set wbExcel = AppExcel.WorkBooks.Open("C:\Program Files\ScriptTest.xls")
Set aSheet = wbExcel.Sheets("Datasheet")
Sess0.Screen.SendKeys("admin ba")
Sess0.Screen.Sendkeys ("<Enter>")
Do While Sess0.Screen.OIA.XStatus <> 0 : Loop
For x = 1 to 1
AccountNum = aSheet.Cells(x,1).text
Sess0.Screen.Sendkeys("<Tab>")
Sess0.Screen.Sendkeys("<EraseEOF>")
Sess0.Screen.Sendkeys (AccountNum)
Sess0.Screen.Sendkeys ("<Enter>")
Do While Sess0.Screen.OIA.XStatus <> 0 : Loop
Sess0.Screen.Sendkeys ("<Enter>")
Do While Sess0.Screen.OIA.XStatus <> 0 : Loop
Sess0.Screen.Sendkeys("<Pf6>")
Do While Sess0.Screen.OIA.XStatus <> 0 : Loop
Sess0.Screen.Sendkeys("<Tab>pc(r<Enter>")
Do While Sess0.Screen.OIA.XStatus <> 0 : Loop
Sess0.Screen.Sendkeys("<Enter>")
Do While Sess0.Screen.OIA.XStatus <> 0 : Loop
Sess0.Screen.Sendkeys("<Pf3>")
Sess0.Screen.Sendkeys("<Pf3>")
Next
For x = 2 to aSheet.UsedRange.Rows.Count
AccountNum = aSheet.Cells(x,1).text
Sess0.Screen.Sendkeys("<EraseEOF>")
Sess0.Screen.Sendkeys("<Tab>")
Sess0.Screen.Sendkeys (AccountNum)
Sess0.Screen.Sendkeys ("<Enter>")
Do While Sess0.Screen.OIA.XStatus <> 0 : Loop
Sess0.Screen.Sendkeys ("<Enter>")
Do While Sess0.Screen.OIA.XStatus <> 0 : Loop
Sess0.Screen.Sendkeys("<Pf6>")
Do While Sess0.Screen.OIA.XStatus <> 0 : Loop
Sess0.Screen.Sendkeys("<Tab>pc(a<Enter>")
Do While Sess0.Screen.OIA.XStatus <> 0 : Loop
Sess0.Screen.Sendkeys("<Enter>")
Do While Sess0.Screen.OIA.XStatus <> 0 : Loop
Sess0.Screen.Sendkeys("<Pf3>")
Sess0.Screen.Sendkeys("<Pf3>")
Next
Msgbox ("The macro has finished.")
Thanks in advance for any insight you can offer.
Here's my code:
Sub Main
Dim appExcel As Object
Dim wbExcel As Object
Dim aSheet As Object
Dim Sessions as Object
Dim System as Object
Dim AccountNum As String
Dim Sess0 as Object
Set System = CreateObject("EXTRA.System")
Set Sessions = System.Sessions
Set Sess0 = System.ActiveSession
If (Sessions is Nothing) Then
Msgbox "Could not create the Sessions collection object. Stopping macro playback."
STOP
End If
Set AppExcel = CreateObject("Excel.Application")
If (System is Nothing) Then
Msgbox "Could not create the EXTRA System object. Stopping macro playback."
STOP
End If
Set wbExcel = AppExcel.WorkBooks.Open("C:\Program Files\ScriptTest.xls")
Set aSheet = wbExcel.Sheets("Datasheet")
Sess0.Screen.SendKeys("admin ba")
Sess0.Screen.Sendkeys ("<Enter>")
Do While Sess0.Screen.OIA.XStatus <> 0 : Loop
For x = 1 to 1
AccountNum = aSheet.Cells(x,1).text
Sess0.Screen.Sendkeys("<Tab>")
Sess0.Screen.Sendkeys("<EraseEOF>")
Sess0.Screen.Sendkeys (AccountNum)
Sess0.Screen.Sendkeys ("<Enter>")
Do While Sess0.Screen.OIA.XStatus <> 0 : Loop
Sess0.Screen.Sendkeys ("<Enter>")
Do While Sess0.Screen.OIA.XStatus <> 0 : Loop
Sess0.Screen.Sendkeys("<Pf6>")
Do While Sess0.Screen.OIA.XStatus <> 0 : Loop
Sess0.Screen.Sendkeys("<Tab>pc(r<Enter>")
Do While Sess0.Screen.OIA.XStatus <> 0 : Loop
Sess0.Screen.Sendkeys("<Enter>")
Do While Sess0.Screen.OIA.XStatus <> 0 : Loop
Sess0.Screen.Sendkeys("<Pf3>")
Sess0.Screen.Sendkeys("<Pf3>")
Next
For x = 2 to aSheet.UsedRange.Rows.Count
AccountNum = aSheet.Cells(x,1).text
Sess0.Screen.Sendkeys("<EraseEOF>")
Sess0.Screen.Sendkeys("<Tab>")
Sess0.Screen.Sendkeys (AccountNum)
Sess0.Screen.Sendkeys ("<Enter>")
Do While Sess0.Screen.OIA.XStatus <> 0 : Loop
Sess0.Screen.Sendkeys ("<Enter>")
Do While Sess0.Screen.OIA.XStatus <> 0 : Loop
Sess0.Screen.Sendkeys("<Pf6>")
Do While Sess0.Screen.OIA.XStatus <> 0 : Loop
Sess0.Screen.Sendkeys("<Tab>pc(a<Enter>")
Do While Sess0.Screen.OIA.XStatus <> 0 : Loop
Sess0.Screen.Sendkeys("<Enter>")
Do While Sess0.Screen.OIA.XStatus <> 0 : Loop
Sess0.Screen.Sendkeys("<Pf3>")
Sess0.Screen.Sendkeys("<Pf3>")
Next
Msgbox ("The macro has finished.")
Thanks in advance for any insight you can offer.