PDA

View Full Version : VBA Reflection Loop Not Working



Jessica D.
09-28-2016, 12:11 PM
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!!!

SamT
09-28-2016, 04:17 PM
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.

SamT
09-28-2016, 04:28 PM
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