Is there anything I can improve on here?

Kurt

Well-known Member
Joined
Jul 23, 2002
Messages
1,664
This is my first stab at using Reflections WRQ. I found some really great posts here that helped me get started. I know I need to get rid of some comments but does anyone see anything I could do different or better?

Code:
6-30 12:03 AM

Public iOutFile As Integer
Sub StepstoSubscriberMemberHistory(strClaimID)
' Generated by the Reflection Macro Recorder on 06-29-2017 09:40:59.80.
' Generated by Reflection for UNIX and OpenVMS 14.0.
    On Error GoTo ErrorHandler

    Const NEVER_TIME_OUT = 0

    Dim CR As String    ' Chr(rcCR) = Chr(13) = Control-M
    Dim SI As String    ' Chr(rcSI) = Chr(15) = Control-O
    Dim ESC As String   ' Chr(rcESC) = Chr(27) = Control-[
    Dim sWriteString As String
    CR = Chr(Reflection2.ControlCodes.rcCR)
    SI = Chr(Reflection2.ControlCodes.rcSI)
    ESC = Chr(Reflection2.ControlCodes.rcESC)

    With Session
        .Transmit "3" & CR

        ' The following string was not unique:
         .WaitForString ESC & "[04;17H       ", NEVER_TIME_OUT, rcAllowKeystrokes

        .StatusBar = "Waiting for Prompt: MEMBER NUMBER:"
        .WaitForString " " & SI & ESC & "[;;4m" & ESC & "[04;17H       ", NEVER_TIME_OUT, rcAllowKeystrokes
        .StatusBar = ""
        .Transmit strClaimID


        .StatusBar = "Waiting for Prompt: MEMBER NUMBER: 8870044-02       NAME:"
        .WaitForString ESC & "[04;40H", NEVER_TIME_OUT, rcAllowKeystrokes
        .StatusBar = ""
        .Transmit CR

        ' The following string was not unique:
         .WaitForString ESC & "[10;02H", NEVER_TIME_OUT, rcAllowKeystrokes

        .WaitForString "           " & SI & ESC & "[;;4m" & ESC & "[10;02H", NEVER_TIME_OUT, rcAllowKeystrokes
        ' Press VtPf1 (Perform the VT terminal PF1 function).
        .TransmitTerminalKey rcVtPF1Key

        ' The following string was not unique:
         .WaitForString ESC & "[24;01H", NEVER_TIME_OUT, rcAllowKeystrokes

        .WaitForString "5" & ESC & "[24;01H", NEVER_TIME_OUT, rcAllowKeystrokes
        .Transmit "o"

        ' The following string was not unique:
         .WaitForString ESC & "[21;51H", NEVER_TIME_OUT, rcAllowKeystrokes

        .StatusBar = "Waiting for Prompt: ENTER OPTION LETTER:"
        .WaitForString " " & SI & ESC & "[;;4m" & ESC & "[21;51H", NEVER_TIME_OUT, rcAllowKeystrokes
        .StatusBar = ""
        .Transmit "g" & CR

        .WaitForString ESC & "[24;80H", NEVER_TIME_OUT, rcAllowKeystrokes
    End With
        With Session
    
        For lRow = 14 To 20
            strRL = .GetText(lRow, 0, lRow, 1)
            Debug.Print strRL
            
            If strRL = "  " Then Exit For
            strTN = .GetText(lRow, 3, lRow, 4)
            Debug.Print strTN
            strLast = .GetText(lRow, 6, lRow, 13)
            Debug.Print strLast
            strFirst = .GetText(lRow, 15, lRow, 23)
            Debug.Print strFirst
            strStartDt = .GetText(lRow, 58, lRow, 65)
            Debug.Print strStartDt
            sWriteString = Trim(strClaimID) & "|" & strRL & "|" & strLast & "|" & strFirst & "|" & strStartDate
            Print #iOutFile, sWriteString
        Next lRow
       End With
'End Function

    
    
    Exit Sub

ErrorHandler:
    Session.MsgBox Err.Description, vbExclamation + vbOKOnly

    ' Recording stopped at 09:42:10.67.
End Sub
Function SubscriberMemberHistory()
    Dim strRL As String
    Dim strTN As String
    Dim strLast As String
    Dim strFirst As String
    Dim strStartDt As String
    Dim lRow As Integer
    
    With Session
    
        For lRow = 14 To 20
            strRL = .GetText(lRow, 0, lRow, 1)
            Debug.Print strRL
            If strRL = "  " Then Exit For
            strTN = .GetText(lRow, 3, lRow, 4)
            Debug.Print strTN
            strLast = .GetText(lRow, 6, lRow, 13)
            Debug.Print strLast
            strFirst = .GetText(lRow, 15, lRow, 23)
            Debug.Print strFirst
            strStartDt = .GetText(lRow, 58, lRow, 65)
            Debug.Print strStartDt
        Next lRow
       End With
End Function
Function ClaimsHistoryInquiry2()
Dim CR As String
CR = Chr(Reflection2.ControlCodes.rcCR)
    
    With Session
        .Transmit "3" & CR
    End With
End Function

Function ClaimsHistoryInquiry()
Dim CR As String
CR = Chr(Reflection2.ControlCodes.rcCR)
    Session.TransmitTerminalKey rcVtF20Key
    Session.TransmitTerminalKey rcVtF1Key & CR
    'Session.Transmit "o"
End Function
Function ClaimInquirySubmenu()
Dim CR As String
CR = Chr(Reflection2.ControlCodes.rcCR)
    
    With Session
        .TransmitTerminalKey rcVtPF1Key
        .Transmit "O"
    End With
End Function
Public Sub EligibilityInquiryScreen()
    'need Shift F10 Num Lock m right here
     With Session
    Session.TransmitTerminalKey rcVtF20Key
        '.Wait 0.25
    Session.TransmitTerminalKey rcVtPF1Key
        '.Wait 0.25
        ' The following string was not unique:
         .WaitForString ESC & "[24;01H", NEVER_TIME_OUT, rcAllowKeystrokes
        .WaitForString "5" & ESC & "[24;01H", NEVER_TIME_OUT, rcAllowKeystrokes
    Session.Transmit "o"
        '.Wait 0.25
    'Session.TransmitTerminalKey rcVtPF1Key
    'Session.Transmit "O"
            .Transmit "G"
            .TransmitTerminalKey rcVtReturnKey
    End With
End Sub

Public Sub GetCommentsMaintenance()
    With Session
        .Transmit "C"
        TransmitTerminalKey rcVtReturnKey
        .Wait 0.25
    End With
End Sub
Function CommentsMaintenance()
    'Dim strComments As String
    Dim strComments2 As String
    Dim strLine As String
    Dim lRow As Integer
    Dim strStatus As String
    Dim intCount As Integer
    Dim strLine1 As String
    strComments2 = ""
    Dim bEOC As Boolean
    bEOC = False
    
    intCount = 0
    
    With Session
        Do While bEOC = False
        'Do While strStatus <> "CO-I-001"
             '"CO-I-001  CANNOT PAGE FWD; NO ADDITIONAL RECORDS TO DISPLAY"
             '"CO-I-002  CANNOT PAGE BACK; NO PRIOR RECORDS TO DISPLAY"
            For lRow = 7 To 15
                
                strLine = .GetText(lRow, 1, lRow, 78)
                If lRow = 7 And strLine = strLine1 Then
                    bEOC = True
                    Exit For
                End If
                If lRow = 7 Then strLine1 = strLine
                If Len(Trim(strLine)) = 0 Then Exit For
                strComments2 = strComments2 & RTrim(strLine) & vbCrLf
                Debug.Print lRow
                Debug.Print strLine
            Next lRow
            
            .TransmitTerminalKey rcVtPF1Key
            .Transmit "F"
            .Wait 0.25
            
            'strStatus = Trim(.GetText(23, 0, 23, 8))
            '
            ' Prevent infinite loop if we get into an error condition and don't advance
            '
            intCount = intCount + 1
            If intCount > 50 Then Exit Do
        Loop
    End With
    CommentsMaintenance = strComments2
   
End Function
Sub StartOver()
    On Error GoTo ErrorHandler

    Const NEVER_TIME_OUT = 0

    Dim SI As String    ' Chr(rcSI) = Chr(15) = Control-O
    Dim ESC As String   ' Chr(rcESC) = Chr(27) = Control-[

    SI = Chr(Reflection2.ControlCodes.rcSI)
    ESC = Chr(Reflection2.ControlCodes.rcESC)

    With Session
        ' Press VtF20 (Perform the Vt F20 function).
        .TransmitTerminalKey rcVtF20Key

        ' The following string was not unique:
         .WaitForString ESC & "[21;51H", NEVER_TIME_OUT, rcAllowKeystrokes

        .StatusBar = "Waiting for Prompt: ENTER OPTION LETTER:"
        .WaitForString " " & SI & ESC & "[;;4m" & ESC & "[21;51H", NEVER_TIME_OUT, rcAllowKeystrokes
        .StatusBar = ""
        ' Press VtPf1 (Perform the VT terminal PF1 function).
        .TransmitTerminalKey rcVtPF1Key

        ' The following string was not unique:
         .WaitForString ESC & "[24;01H", NEVER_TIME_OUT, rcAllowKeystrokes

        .WaitForString "5" & ESC & "[24;01H", NEVER_TIME_OUT, rcAllowKeystrokes
        .Transmit "m"

        ' The following string was not unique:
         .WaitForString ESC & "[22;12H", NEVER_TIME_OUT, rcAllowKeystrokes
         .WaitForString "m" & ESC & "[22;12H", NEVER_TIME_OUT, rcAllowKeystrokes
    End With
    Exit Sub

ErrorHandler:
    Session.MsgBox Err.Description, vbExclamation + vbOKOnly

    ' Recording stopped at 13:10:16.26.
    
End Sub
Sub NumLockO()
' Generated by the Reflection Macro Recorder on 06-29-2017 10:31:04.71.
' Generated by Reflection for UNIX and OpenVMS 14.0.
    On Error GoTo ErrorHandler

    Const NEVER_TIME_OUT = 0

    Dim SI As String    ' Chr(rcSI) = Chr(15) = Control-O
    Dim ESC As String   ' Chr(rcESC) = Chr(27) = Control-[

    SI = Chr(Reflection2.ControlCodes.rcSI)
    ESC = Chr(Reflection2.ControlCodes.rcESC)

    With Session
        ' Press VtPf1 (Perform the VT terminal PF1 function).
        .TransmitTerminalKey rcVtPF1Key

        ' The following string was not unique:
         .WaitForString ESC & "[24;01H", NEVER_TIME_OUT, rcAllowKeystrokes

        .WaitForString "5" & ESC & "[24;01H", NEVER_TIME_OUT, rcAllowKeystrokes
        .Transmit "o"

        ' The following string was not unique:
         .WaitForString ESC & "[21;51H", NEVER_TIME_OUT, rcAllowKeystrokes
         .WaitForString " " & SI & ESC & "[;;4m" & ESC & "[21;51H", NEVER_TIME_OUT, rcAllowKeystrokes
    End With
    Exit Sub

ErrorHandler:
    Session.MsgBox Err.Description, vbExclamation + vbOKOnly

    ' Recording stopped at 10:31:20.83.
End Sub
Function ReadNotepad()
Dim strFilename As String: strFilename = "C:\Users\kurt.nichols.CCA-AUDIT\My Documents\ClaimIDs.txt"
Dim strOutputFilename As String: strOutputFilename = "C:\Users\kurt.nichols.CCA-AUDIT\My Documents\Results.txt"
Dim strOutputCommentsFilename As String: strOutputCommentsFilename = "C:\Users\kurt.nichols.CCA-AUDIT\My Documents\Comments.txt"
'Debug.Print strFilename
Dim strTextLine As String
Dim strComments As String
Debug.Print strTextLine
Dim iFile As Integer
Dim iOutCommentsFile As Integer
    
    iOutFile = FreeFile
    Open strOutputFilename For Output As #iOutFile
    iOutCommentsFile = FreeFile
    Open strOutputCommentsFilename For Output As #iOutCommentsFile
    
    iFile = FreeFile
    Open strFilename For Input As #iFile
        Do Until EOF(iFile)
            Line Input #iFile, strTextLine
            Debug.Print strTextLine
            sClaimLineToWrite = strTextLine & "|"
            With Session
                StepstoSubscriberMemberHistory (strTextLine)
                    .Wait 0.25
                    .TransmitTerminalKey rcVtF20Key
                    .StatusBar = "Waiting for Prompt: 30-JUN-2017 08:54"
                    '.WaitForString ESC & "[18;20H", NEVER_TIME_OUT, rcAllowKeystrokes
                    .StatusBar = ""
                    ' Press VtPf1 (Perform the VT terminal PF1 function).
                    .TransmitTerminalKey rcVtPF1Key
                    .Transmit "o"
            
                    ' The following string was not unique:
                    ' .WaitForString ESC & "[21;51H", NEVER_TIME_OUT, rcAllowKeystrokes
            
                    .StatusBar = "Waiting for Prompt: ENTER OPTION LETTER:"
                    '.WaitForString " " & SI & ESC & "[;;4m" & ESC & "[21;51H", NEVER_TIME_OUT, rcAllowKeystrokes
                    .StatusBar = ""
                    .Transmit "c" & CR
               GetCommentsMaintenance
                
                    strComments = CommentsMaintenance()
                    strComments = Replace(strComments, vbLf, "**CRLF HERE**")
                    If Len(Trim(strComments)) = 0 Then
                        Print #iOutCommentsFile, Trim(strTextLine) & "|" & "No Comments"
                    Else
                        Print #iOutCommentsFile, Trim(strTextLine) & "|" & strComments
                    End If
                    .TransmitTerminalKey rcVtF20Key
                    .TransmitTerminalKey rcVtPF1Key
                    .Transmit "M"
                    TransmitTerminalKey rcVtReturnKey
                    .Wait 0.25
                    
                    .Wait 0.25
            End With
        Loop
    Close #iFile
    Close #iOutFile
    Close #iOutCommentsFile
End Function

Any help and/or comments is always appreciated. Have a great 4th of July everyone in the USA and stay safe!
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

Forum statistics

Threads
1,214,944
Messages
6,122,392
Members
449,081
Latest member
JAMES KECULAH

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top