Consulting

Results 1 to 3 of 3

Thread: VBA Reflection Loop Not Working

  1. #1

    VBA Reflection Loop Not Working

    I tried to look all over the place for an answer, but I'm new to coding for my call center and really need some help. Here is what I'm trying to accomplish:
    In Reflection, I am trying to search for a specific string within a set of rows. If the string is not on the first row, I want the cursor to move down to the next row and search for the string (repeating until the string is found on a row). Once the string is found, I want the cursor to select that row.
    I have included my code which isn't working but hopefully will help:
    -Sub gynbereferral()
    -Const NEVER_TIME_OUT = 0
    -Dim LF As String ' Chr(rcLF) = Chr(10) = Control-J
    -Dim CR As String ' Chr(rcCR) = Chr(13) = Control-M
    -Dim ESC As String ' Chr(rcESC) = Chr(27) = Control-[
    -LF = Chr(Reflection2.ControlCodes.rcLF)
    -CR = Chr(Reflection2.ControlCodes.rcCR)
    -ESC = Chr(Reflection2.ControlCodes.rcESC)

    -With Session
    -Dim Reflection As Object
    -Set Reflection = GetObject(, "Reflection2.Session")
    -Dim LastColumn As Integer
    -LastColumn = .DisplayColumns
    -Dim cursorRow As Integer
    -cursorRow = .cursorRow
    -Dim screen_name As String
    -screen_name = Reflection.GetText(0, 32, 0, 47)
    -Dim ploc_name As String
    -ploc_name = Reflection.GetText(cursorRow, 0, cursorRow, LastColumn)
    -Dim Text As String
    -Text = Reflection.GetText(cursorRow, 0, cursorRow, LastColumn)

    -.Transmit "r" & CR
    -.Transmit "m" & CR
    -.Wait ("1")
    -ploc_name = Reflection.GetText(cursorRow, 0, cursorRow, LastColumn)
    -Do
    -If ploc_name Like "*GYBEGP*" Then
    -.TransmitTerminalKey rcVtSelectKey
    -.Transmit CR
    -.Transmit CR
    -.Transmit CR
    -.Transmit CR
    -.Transmit CR
    -.Transmit CR
    -.Transmit CR
    -.Transmit CR
    -.Transmit CR
    -.Transmit CR
    -.Transmit CR
    -.TransmitTerminalKey rcVtRemoveKey
    -.Transmit "99"
    -.TransmitTerminalKey rcVtEnterKey
    -.TransmitTerminalKey rcVtRemoveKey
    -.Transmit "ftr" & CR
    -.Transmit CR
    -.Transmit CR
    -.Transmit "+90" & CR
    -.Transmit CR
    -.Transmit CR
    -.Transmit CR
    -.Transmit CR
    -.Transmit CR
    -.Transmit CR
    -.Transmit CR
    -.Transmit CR
    -.Transmit CR
    -.Transmit CR
    -.Transmit CR
    -.Transmit CR
    -.Transmit CR
    -.Transmit CR
    -.Transmit CR
    -.Transmit CR
    -.StatusBar = "Waiting for Prompt: File changes and exit."
    -.WaitForString ESC & "[KFile changes and exit.", NEVER_TIME_OUT, -rcAllowKeystrokes
    -.StatusBar = ""
    -.Transmit CR
    -.StatusBar = "Waiting for Prompt: Print (L)ist, or (Q)uit:"
    -.WaitForString LF & " Print (L)ist, or (Q)uit: ", NEVER_TIME_OUT, -rcAllowKeystrokes
    -.StatusBar = ""
    -.Transmit "b" & CR
    -.TransmitTerminalKey rcVtSelectKey
    -Else
    -.TransmitTerminalKey rcVtDownKey
    -ploc_name = Reflection.GetText(cursorRow, 0, cursorRow, LastColumn)
    -Loop Until ploc_name Like "*GYBEGP*"
    -Loop
    -Do
    -If ploc_name Like "*GYBEGP*" Then
    -.TransmitTerminalKey rcVtSelectKey
    -Else
    -.Wait ("3")
    -.TransmitTerminalKey rcVtDownKey
    -.Wait ("3")
    -ploc_name = Reflection.GetText(cursorRow, 0, cursorRow, LastColumn)
    -Loop Until ploc_name Like "*GYBEGP*"
    -Loop
    Sometimes I can get my loop to work but it won't stop looping, like it it's looking for the GYBEGP string.
    PLEASE HELP!!!

  2. #2
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Please. . .

    Click the # Icon in this editors menu. That will insert CODE tags into your post.

    Then simply copy your code in you Workbook and paste it between the Code Tags.

    That will nicely format your code when you click Post Quick Reply.

    BTW, If you Go Advanced, The Paper Clip Icon on the Advanced Editor's menu will let you upload workbooks and other files.
    Last edited by SamT; 09-28-2016 at 04:29 PM.
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

  3. #3
    Moderator VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,814
    Location
    Here is the top index for the Reflection help files. You need to tell us which version of Reflection you are using. The Helps include VBA Reference material.

    http://support.attachmate.com/product/choose.html
    I expect the student to do their homework and find all the errrors I leeve in.


    Please take the time to read the Forum FAQ

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •