Macro_Maniac
New Member
- Joined
- Nov 16, 2014
- Messages
- 43
Dear experts,
Am trying to build a small utility which extracts the status from a mainframe application..
This is the first time am attempting to write a VBA macro, so pls help.
Managed to write a code as below and this works fine for the first record where,
1. It picks the REF,
2. inputs in the application,
3. retrieves the status and
4. paste it in the excel.
However the problem is, it doesn't move to next ref in col D and I want it to continue above 4 steps utill it get hits by a blank cell in col D
==========================
Sub REF()
Dim Srow As Double
Dim rowindex As Integer
Dim REFIndex As Integer
Dim SCRowIndex As Integer
Dim REF As Variant
'ref is available from row 3, in col D
rowindex = 3
REFIndex = 4
Srow = 3
Do
Application.ScreenUpdating = False
Sheets("sheet1").Activate
'reference are maintained in col D
For Each REF In Sheets("sheet1").Range("D:D")
If REF = "" Then
End If
' trim REF and then copy ref.
REF = Trim(Cells(rowindex, REFIndex))
Sheets("sheet1").Cells(1 + Srow, 4).Copy
'Paste REF in application anc check the status
autECLOIA.WaitForAppAvailable
autECLOIA.WaitForInputReady
autECLPS.SetCursorPos 21, 13
autECLPS.SendKeys (REF)
autECLPS.SendKeys "[enter]"
'get the status from the screen and update in excel col F (same row, col D from where REF was picked)
If autECLPS.GetText(1, 2, 6) = "MI031" Then
Cells(Srow, "f").Value = autECLPS.GetText(5, 28, 5) 'Status
End If
autECLPS.SendKeys "[enter]"
autECLOIA.WaitForAppAvailable
autECLOIA.WaitForInputReady
Cells(Srow, "f").Value = autECLPS.GetText(5, 28, 5) 'Status
Next REF
Exit Do
Loop
End Sub
==========================
Am trying to build a small utility which extracts the status from a mainframe application..
This is the first time am attempting to write a VBA macro, so pls help.
Managed to write a code as below and this works fine for the first record where,
1. It picks the REF,
2. inputs in the application,
3. retrieves the status and
4. paste it in the excel.
However the problem is, it doesn't move to next ref in col D and I want it to continue above 4 steps utill it get hits by a blank cell in col D
==========================
Sub REF()
Dim Srow As Double
Dim rowindex As Integer
Dim REFIndex As Integer
Dim SCRowIndex As Integer
Dim REF As Variant
'ref is available from row 3, in col D
rowindex = 3
REFIndex = 4
Srow = 3
Do
Application.ScreenUpdating = False
Sheets("sheet1").Activate
'reference are maintained in col D
For Each REF In Sheets("sheet1").Range("D:D")
If REF = "" Then
End If
' trim REF and then copy ref.
REF = Trim(Cells(rowindex, REFIndex))
Sheets("sheet1").Cells(1 + Srow, 4).Copy
'Paste REF in application anc check the status
autECLOIA.WaitForAppAvailable
autECLOIA.WaitForInputReady
autECLPS.SetCursorPos 21, 13
autECLPS.SendKeys (REF)
autECLPS.SendKeys "[enter]"
'get the status from the screen and update in excel col F (same row, col D from where REF was picked)
If autECLPS.GetText(1, 2, 6) = "MI031" Then
Cells(Srow, "f").Value = autECLPS.GetText(5, 28, 5) 'Status
End If
autECLPS.SendKeys "[enter]"
autECLOIA.WaitForAppAvailable
autECLOIA.WaitForInputReady
Cells(Srow, "f").Value = autECLPS.GetText(5, 28, 5) 'Status
Next REF
Exit Do
Loop
End Sub
==========================
Last edited: