Hello all,
It's been a long time since I posted on here, I've learned a lot since my last post.
I need some help to get around an issue, I'm struggling between using a stage method "if this go to 2, else go to 1" or try to create a thread of loops.
The goal is to create a macro that feeds from excel and validates a few screens status, then trims information until it finds a designated string. I've hit a wall and struggling with the loop path. I've started it as a sample but the more I do the less I think it will work. The initial stage method is also there in "full". I can revise if needed but I think most can make do and provide some advice.
I don't need the script written for me, just some input on the best method. Thanks!
Sub RunStrmClean()
Set objSession = GetObject("C:\Users\krwrigh\Desktop\CPI.edp")
Set objscreen = objSession.Screen
Dim Active As String
Dim Change As String
Dim Client As String
Dim L14 As String
Dim L14status As String
Dim LMT1 As String
Dim LMT3 As String
Dim LN As String
Dim Loan As String
Dim Loanstatus As String
Dim M44 As String
Dim M44CODE As String
Dim M44date As String
Dim N As String
Dim Setupdate As String
Dim Stepcode As String
LN = 9
M44CODE = Cells(4, 1)
Change = Cells(4, 2)
LMT3 = Cells(4, 3)
L14 = Cells(4, 6)
LMT1 = Cells(4, 4)
Active = Cells(4, 5)
Client = Cells(LN, 1)
Do Until Client = Empty
objscreen.SendKeys ("<clear><clear><clear>")
objscreen.SendKeys ("TMID<enter>")
objscreen.WaitHostQuiet (xtraSettleTime)
MSP = Trim(objscreen.getstring(9, 49, 3))
Do Until Client = MSP
Cancel = MsgBox("Please log into client " & Client, vbOKCancel, "Client Error")
If Cancel = "2" Then
GoTo Endnow
Else
objscreen.SendKeys ("<clear><clear><clear>")
objscreen.SendKeys ("TMID<enter>")
objscreen.WaitHostQuiet (xtraSettleTime)
MSP = Trim(objscreen.getstring(9, 49, 3))
End If
Loop
1 Do Until Loan = Empty
N = 6
Loan = Cells(LN, 2)
objscreen.SendKeys ("<home>") & LMT1 & Loan & ("<enter>")
Setupdate = Trim(objscreen.getstring(11, 5, 6))
Loanstatus = Trim(objscreen.getstring(7, 5, 1))
If Loanstatus = Active Then
GoTo 2
Else
Do Until LN = Empty
LN = LN + 1
GoTo 1
Loop
End If
Loop
2
Endnow:
' this is the initial path, validating the TMID screen will be incorporated later.
1 'Validate the loan is active in loss mit
N = 6
Loan = Cells(LN, 2)
LMT1 = Cells(4, 4)
Active = Cells(4, 5)
objscreen.SendKeys ("<clear><clear><clear>")
objscreen.SendKeys ("<home>") & LMT1 & Loan & ("<enter>")
Setupdate = Trim(objscreen.getstring(11, 5, 6))
Loanstatus = Trim(objscreen.getstring(7, 5, 1))
If Loanstatus = Active Then
GoTo 2
Else
LN = LN + 1
If LN = "" Then
GoTo 11
Else
GoTo 1
2 'Begin looking for L14 StepCode
objscreen.SendKeys ("<home>") & LMT3 & Loan & ("<enter>")
Stepcode = Trim(objscreen.getstring(N, 20, 3))
If Stecode = L14 Then
GoTo 4
Else
N = N + 1
If N = 23 Then
GoTo 3
Else
GoTo 2
3 'Change page after reaching the last step code in current page without being L14
objscreen.SendKeys ("<Pf8>")
N = 6
GoTo 2
4 'After finding L14 step code check on the date status
L14status = Trim(objscreen.getstring(N, 13, 6))
If L14status = "" Then
GoTo 5
Else
LN = LN + 1
GoTo 1
5 'Begin looking for M44 if L14 is blank
N = 6
M44 = Trim(objscreen.getstring(N, 20, 3))
If M44 = M44CODE Then
GoTo 6
Else
N = N + 1
GoTo 5
6 'Capture M44 date after locating M44 step code
M44date = Trim(objscreen.getstring(N, 13, 6))
If M44date = "" Then
GoTo 7
Else
GoTo 8
7 'If M44 is blank, using LMT1 Setup date
objscreen.putstring Change, N, 2
objscreen.WaitHostQuiet (xtraSettleTime)
objscreen.SendKeys ("<enter>")
objscreen.putstring Setupdate, N, 13
objscreen.WaitHostQuiet (xtraSettleTime)
objscreen.SendKeys ("<enter>")
M44date = Trim(objscreen.getstring(N, 13, 6))
GoTo 8
8 'Begin looking for L14 again
objscreen.SendKeys ("<home>") & LMT3 & Loan & ("<enter>")
Stepcode = Trim(objscreen.getstring(N, 20, 3))
If Stecode = L14 Then
GoTo 10
Else
N = N + 1
If N = 23 Then
GoTo 9
Else
GoTo 8
9 'Change page after reaching the last step code in current page without being L14
objscreen.SendKeys ("<Pf8>")
N = 6
GoTo 8
10
objscreen.putstring Change, N, 2
objscreen.WaitHostQuiet (xtraSettleTime)
objscreen.SendKeys ("<enter>")
objscreen.putstring M44date, N, 13
objscreen.WaitHostQuiet (xtraSettleTime)
objscreen.SendKeys ("<enter>")
LN = LN + 1
If LN = "" Then
GoTo 11
Else
GoTo 1
11
MsgBox "Macro Complete"
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End Sub
It's been a long time since I posted on here, I've learned a lot since my last post.
I need some help to get around an issue, I'm struggling between using a stage method "if this go to 2, else go to 1" or try to create a thread of loops.
The goal is to create a macro that feeds from excel and validates a few screens status, then trims information until it finds a designated string. I've hit a wall and struggling with the loop path. I've started it as a sample but the more I do the less I think it will work. The initial stage method is also there in "full". I can revise if needed but I think most can make do and provide some advice.
I don't need the script written for me, just some input on the best method. Thanks!
Sub RunStrmClean()
Set objSession = GetObject("C:\Users\krwrigh\Desktop\CPI.edp")
Set objscreen = objSession.Screen
Dim Active As String
Dim Change As String
Dim Client As String
Dim L14 As String
Dim L14status As String
Dim LMT1 As String
Dim LMT3 As String
Dim LN As String
Dim Loan As String
Dim Loanstatus As String
Dim M44 As String
Dim M44CODE As String
Dim M44date As String
Dim N As String
Dim Setupdate As String
Dim Stepcode As String
LN = 9
M44CODE = Cells(4, 1)
Change = Cells(4, 2)
LMT3 = Cells(4, 3)
L14 = Cells(4, 6)
LMT1 = Cells(4, 4)
Active = Cells(4, 5)
Client = Cells(LN, 1)
Do Until Client = Empty
objscreen.SendKeys ("<clear><clear><clear>")
objscreen.SendKeys ("TMID<enter>")
objscreen.WaitHostQuiet (xtraSettleTime)
MSP = Trim(objscreen.getstring(9, 49, 3))
Do Until Client = MSP
Cancel = MsgBox("Please log into client " & Client, vbOKCancel, "Client Error")
If Cancel = "2" Then
GoTo Endnow
Else
objscreen.SendKeys ("<clear><clear><clear>")
objscreen.SendKeys ("TMID<enter>")
objscreen.WaitHostQuiet (xtraSettleTime)
MSP = Trim(objscreen.getstring(9, 49, 3))
End If
Loop
1 Do Until Loan = Empty
N = 6
Loan = Cells(LN, 2)
objscreen.SendKeys ("<home>") & LMT1 & Loan & ("<enter>")
Setupdate = Trim(objscreen.getstring(11, 5, 6))
Loanstatus = Trim(objscreen.getstring(7, 5, 1))
If Loanstatus = Active Then
GoTo 2
Else
Do Until LN = Empty
LN = LN + 1
GoTo 1
Loop
End If
Loop
2
Endnow:
' this is the initial path, validating the TMID screen will be incorporated later.
1 'Validate the loan is active in loss mit
N = 6
Loan = Cells(LN, 2)
LMT1 = Cells(4, 4)
Active = Cells(4, 5)
objscreen.SendKeys ("<clear><clear><clear>")
objscreen.SendKeys ("<home>") & LMT1 & Loan & ("<enter>")
Setupdate = Trim(objscreen.getstring(11, 5, 6))
Loanstatus = Trim(objscreen.getstring(7, 5, 1))
If Loanstatus = Active Then
GoTo 2
Else
LN = LN + 1
If LN = "" Then
GoTo 11
Else
GoTo 1
2 'Begin looking for L14 StepCode
objscreen.SendKeys ("<home>") & LMT3 & Loan & ("<enter>")
Stepcode = Trim(objscreen.getstring(N, 20, 3))
If Stecode = L14 Then
GoTo 4
Else
N = N + 1
If N = 23 Then
GoTo 3
Else
GoTo 2
3 'Change page after reaching the last step code in current page without being L14
objscreen.SendKeys ("<Pf8>")
N = 6
GoTo 2
4 'After finding L14 step code check on the date status
L14status = Trim(objscreen.getstring(N, 13, 6))
If L14status = "" Then
GoTo 5
Else
LN = LN + 1
GoTo 1
5 'Begin looking for M44 if L14 is blank
N = 6
M44 = Trim(objscreen.getstring(N, 20, 3))
If M44 = M44CODE Then
GoTo 6
Else
N = N + 1
GoTo 5
6 'Capture M44 date after locating M44 step code
M44date = Trim(objscreen.getstring(N, 13, 6))
If M44date = "" Then
GoTo 7
Else
GoTo 8
7 'If M44 is blank, using LMT1 Setup date
objscreen.putstring Change, N, 2
objscreen.WaitHostQuiet (xtraSettleTime)
objscreen.SendKeys ("<enter>")
objscreen.putstring Setupdate, N, 13
objscreen.WaitHostQuiet (xtraSettleTime)
objscreen.SendKeys ("<enter>")
M44date = Trim(objscreen.getstring(N, 13, 6))
GoTo 8
8 'Begin looking for L14 again
objscreen.SendKeys ("<home>") & LMT3 & Loan & ("<enter>")
Stepcode = Trim(objscreen.getstring(N, 20, 3))
If Stecode = L14 Then
GoTo 10
Else
N = N + 1
If N = 23 Then
GoTo 9
Else
GoTo 8
9 'Change page after reaching the last step code in current page without being L14
objscreen.SendKeys ("<Pf8>")
N = 6
GoTo 8
10
objscreen.putstring Change, N, 2
objscreen.WaitHostQuiet (xtraSettleTime)
objscreen.SendKeys ("<enter>")
objscreen.putstring M44date, N, 13
objscreen.WaitHostQuiet (xtraSettleTime)
objscreen.SendKeys ("<enter>")
LN = LN + 1
If LN = "" Then
GoTo 11
Else
GoTo 1
11
MsgBox "Macro Complete"
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End Sub