# Reflections WRQ VBA



## Robertson1995 (Apr 22, 2009)

I have the following code that I use in WRQ Reflections. It is very basic and runs the command bts_status mc800bts877. The characters "877" which are in red below is a site # which changes. What I need is for the macro to run the command bts_status mc800bts and then have an inputbox ask for the next 3 characters (in this example 877) that then carriage return after ok is selected on the input box. Thanks.


Sub Macro1()
' Generated by the Reflection Macro Recorder on 04-22-2009 09:01:25.57.
' Generated by Reflection for UNIX and Digital 8.0.6.
    On Error GoTo ErrorHandler
    Const NEVER_TIME_OUT = 0
    Dim CR As String    ' Chr$(rcCR) = Chr$(13) = Control-M
    Dim ESC As String   ' Chr$(rcESC) = Chr$(27) = Control-[
    CR = Chr$(rcCR)
    ESC = Chr$(rcESC)
    With Session
        .Transmit "bts_status mc800bts877" & CR
        ' .WaitForString ESC & "[K", NEVER_TIME_OUT, rcAllowKeystrokes
    Exit Sub
ErrorHandler:
    .MsgBox Err.Description, vbExclamation + vbOKOnly
    End With
    ' Recording stopped at 09:04:44.83.
End Sub


----------



## schielrn (Apr 22, 2009)

Maybe try:


```
Sub Macro1()
' Generated by the Reflection Macro Recorder on 04-22-2009 09:01:25.57.
' Generated by Reflection for UNIX and Digital 8.0.6.
On Error GoTo ErrorHandler
ibValue = inputbox("Enter Site Number")
Const NEVER_TIME_OUT = 0
Dim CR As String ' Chr$(rcCR) = Chr$(13) = Control-M
Dim ESC As String ' Chr$(rcESC) = Chr$(27) = Control-[
CR = Chr$(rcCR)
ESC = Chr$(rcESC)
With Session
.Transmit "bts_status mc800bts" & ibValue & CR
' .WaitForString ESC & "[K", NEVER_TIME_OUT, rcAllowKeystrokes
Exit Sub
ErrorHandler:
.MsgBox Err.Description, vbExclamation + vbOKOnly
End With
' Recording stopped at 09:04:44.83.
End Sub
```
You could probably limit the inout to integers if that is what will always be entered or create a loop to make sure a value is entered, but this should get you started.

Hope that helps.


----------



## Robertson1995 (Apr 22, 2009)

It's working. Thanks for your help. There is another thing I would like to do with this a similar command using a Userform. I am new to userforms and I am trying to learn VBA, so I may not be asking this question correctly, but let me try. 

I have built a macro using the answer from your reply and here's the command it runs:

1. cd 0%:cbs1:cells1:mc800bts (no carriage return)
2. After the above command is listed at the prompt, the inputbox pops up and asks for the site number which results in cd 0%:cbs1:cells:mc800bts600.
3. then the text :mcBTSSubsystem1:Root1: is added resulting in this command:

0%:cbs1:cells:mc800bts600:mcBTSSubsystem1:Root1:

It is working great up to this point.

Now from this point the command requires that we enter either CEM1, CEM2, or CEM3. I would like for a user form to popup with these 3 options on it and whichever one I choose it would run. For example if I click CEM1 on the userform it would run the following command:

0%:cbs1:cells:mc800bts600:mcBTSSubsystem1:Root1:CEM1;

Hope this makes sense. Being new to userforms, I may not even be building the macro in the form correctly.


----------



## schielrn (Apr 23, 2009)

Yes, you would be correct in using a userform.  I have not done a userform or really that much coding at all in reflections to know the code to well.  But I would say it should be a pretty simple userform that contains 3 buttons.

Then within the code for the 3 buttons, you could have it run the command based on CEM 1, 2 or 3.

It shouldn't be that hard of a task to accomplish, but if you need some help with the code after getting the userform setup and setting up some on click events I think is what you would want to.  Something like this with a userform with 3 buttons:


```
Private Sub CommandButton1_Click()
'Call 1st code
End Sub
 
Private Sub CommandButton2_Click()
'Call 2nd code
End Sub
 
Private Sub CommandButton3_Click()
'Call 3rd code
End Sub
```
You would just call the module that you have building the string and then add CEM1 or whichever to the end of the sreing depending on the button they pushed.

Hope that helps and post back with any other questions and the complete code as you have it, if you need more help.


----------



## ry94080 (May 20, 2009)

I too code in Reflection VBA,

Does anyone know how to open a file dialog box in reflection VBA, i can't seem to do it...????


----------



## schielrn (May 21, 2009)

This is what I use to open a file dialog box and let them choose an excel 2007 file, you can adjust it for different file types:


```
Set oXLApp = New Excel.Application  'Create a new instance of Excel
strBook = oXLApp.GetOpenFilename(FileFilter:="Excel Files (*.xlsx),*.xlsx", Title:="Open a File", MultiSelect:=False)
If Len(strBook) < 6 Then Exit Sub
Set oXLBook = oXLApp.Workbooks.Open(strBook) 'Open an existing workbook
```
Hope that helps.


----------



## ry94080 (May 21, 2009)

schielrn said:


> This is what I use to open a file dialog box and let them choose an excel 2007 file, you can adjust it for different file types:
> 
> 
> ```
> ...



schielrn, you're a lifesaver. works perfectly!


----------



## ry94080 (May 21, 2009)

schielrn said:


> This is what I use to open a file dialog box and let them choose an excel 2007 file, you can adjust it for different file types:
> 
> 
> ```
> ...



Hi schielrn,

Is it possible to default to a certain directory when the file dialog box opens?


----------



## schielrn (May 21, 2009)

Also just so you know this will not make the workbook visible after it is opened, it will leave it behind the scenes which is what I do for a lot of work, but this will make the aopplication visible:


```
oXLApp.Visible = True               'Show it to the user
```
Hope that helps.


----------



## schielrn (May 21, 2009)

ry94080 said:


> Hi schielrn,
> 
> Is it possible to default to a certain directory when the file dialog box opens?


It is probably possible, but I don't think so using getopenfilename.  I think you'd have to use another approach for opening a file and I don't have time at the moment to research that.  Maybe someone else will come along and know the command.


----------



## Robertson1995 (Apr 22, 2009)

I have the following code that I use in WRQ Reflections. It is very basic and runs the command bts_status mc800bts877. The characters "877" which are in red below is a site # which changes. What I need is for the macro to run the command bts_status mc800bts and then have an inputbox ask for the next 3 characters (in this example 877) that then carriage return after ok is selected on the input box. Thanks.


Sub Macro1()
' Generated by the Reflection Macro Recorder on 04-22-2009 09:01:25.57.
' Generated by Reflection for UNIX and Digital 8.0.6.
    On Error GoTo ErrorHandler
    Const NEVER_TIME_OUT = 0
    Dim CR As String    ' Chr$(rcCR) = Chr$(13) = Control-M
    Dim ESC As String   ' Chr$(rcESC) = Chr$(27) = Control-[
    CR = Chr$(rcCR)
    ESC = Chr$(rcESC)
    With Session
        .Transmit "bts_status mc800bts877" & CR
        ' .WaitForString ESC & "[K", NEVER_TIME_OUT, rcAllowKeystrokes
    Exit Sub
ErrorHandler:
    .MsgBox Err.Description, vbExclamation + vbOKOnly
    End With
    ' Recording stopped at 09:04:44.83.
End Sub


----------



## xcruc1at3r (May 21, 2012)

am using the WRQ Reflection for IBM 3270  i need to Run a Macro In  Reflection to copy data from Excel and paste it into Reflection 
i dont know how to do that!!... i have created a example of vba for you to understand a create a vba macro from it 
i have data in excel Column A and B  
1st I need to Copy data from A1 and paste it into Reflection Position  .WaitForEvent rcEnterPos, "30", "0", 3, 11 & after that it will move  to next screen and have to copy data from B1 and paste it in position          .WaitForEvent rcEnterPos, "30", "0", 4, 11 
        .WaitForDisplayString "SEALS..:", "30", 4, 2 and enter and this process should continue till the last cell with data   
If required i can upload a Excel File with Screen Shots of Reflection Screens and positions

```
Sub macro3() 
 
With Session 
 
Dim excelwb As Object 
Dim z As Integer 
Set excelwb = GetObject(, "Excel.Application") 
Set excelwb = GetObject("C:\Documents and Settings\mintezar\Desktop\Book1.xls") 
z = excelwb.Worksheets("Load").Range("A 1").Value 
    Selection.Copy 
        .WaitForEvent rcEnterPos, "30", "0", 3, 11 
        .WaitForDisplayString "NBR:", "30", 3, 6 
        .Paste 
        .TransmitTerminalKey rcIBMEnterKey 
    End With 
End Sub
```


----------



## schielrn (May 30, 2012)

I've never tried to use the paste feature in reflections if it is even available I am not sure? But here is some sample code where you can see how I get excel values populated to the screen and using a loop to go from row 2 to the last row of column A:


```
Sub AcctAdds()
Dim oXLApp As Excel.Application     'Declare the object variable
Dim oXLBook As Excel.Workbook       'Declare the workbook variable
Dim oXLSheet As Excel.Worksheet     'Declare the sheet variable
Dim oXLCell As Excel.Range          'Declare the range variable
If Session.GetDisplayText(1, 25, 23) <> "G/L ACCOUNT MAINTENANCE" Then
    MsgBox "You are not on the G/L Account Maintenance screen."
    Exit Sub
End If
Set oXLApp = New Excel.Application  'Create a new instance of Excel
strBook = oXLApp.GetOpenFilename(FileFilter:="Excel Files (*.xls*),*.xls*", Title:="Open a File To Check Product Lines", MultiSelect:=False)
If Len(strBook) < 6 Then Exit Sub
Set oXLBook = oXLApp.Workbooks.Open(strBook) 'Open an existing workbook
Set oXLSheet = oXLBook.Worksheets(1)
oXLApp.Visible = True               'Show it to the user
oXLSheet.Select
For a = 2 To oXLSheet.Cells(Rows.Count, 1).End(xlUp).Row
    With Session
        .SetMousePos 5, 26
        .TerminalMouse rcLeftClick, rcMouseRow, rcMouseCol
        .WaitForEvent rcEnterPos, "30", "0", 5, 26
        .TransmitANSI "A"
        .WaitForEvent rcEnterPos, "30", "0", 7, 26
        .TransmitANSI oXLSheet.Cells(a, 1).Value
        .WaitForEvent rcEnterPos, "30", "0", 10, 26
       .TransmitANSI oXLSheet.Cells(a, 3).Value
        .TransmitTerminalKey rcIBMEnterKey
        .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
        .WaitForEvent rcEnterPos, "30", "0", 5, 17
        .WaitForDisplayString "Company", "30", 2, 3
        .SetMousePos 5, 17
        .TerminalMouse rcLeftClick, rcMouseRow, rcMouseCol
        .WaitForEvent rcEnterPos, "30", "0", 5, 17
       .TransmitANSI oXLSheet.Cells(a, 4).Value
```
Hope this makes some sense. Basically the lines in red are where I am inserting the values from Excel in the correct places.


----------



## xcruc1at3r (May 30, 2012)

well am realllyyyyyyyyy glad that you replied .... thanks alottttt...
well as i was waiting for your reply i tried to add some of my efforts so that i can reach some where soo i created this code :
for clear understand Note : 
Set excelApp = GetObject(, "Excel.Application")
Set excelApp = GetObject("C:\Documents and Settings\mintezar\Desktop\Book1.xlsx")
z = excelApp.ActiveSheet.Range("B2").Copy  <<<< copies the  data from Cell B2 and paste it in the software >>> like this  >> .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
.WaitForEvent rcEnterPos, "30", "0", 3, 11
.WaitForDisplayString "NBR:", "30", 3, 6  ( this is were it pastes)
.Paste
.TransmitTerminalKey rcIBMEnterKey << Enter the new screen comes up then goes to C2
z = excelApp.ActiveSheet.Range("C2").Copy
.WaitForEvent rcEnterPos, "30", "0", 1, 80 << NEW screen
.WaitForDisplayString "UPDATE(Y/N):", "30", 1, 67 << cursor default position
.MoveCursor 4, 11 >> move cursor to 4 column, 11 row
.WaitForDisplayString "SEALS..:", "30", 4, 2
.Paste Well this process start from B2 and is till B4 well and my data  varies from 500 to 1200 entries so is there any possibility that this  process be made for Dynamic range ? 
Steps :
if you could add the Loop in it and create a code and i'll test it and let you know the result !
am confused
1st phase it to connect reflection with Excel
2nd phase is to login
3rd goes to the Screen
4th Copies B2 cell data and Paste in the screen and enters
and then Copies C2 data, move cursor  to 4, 11 and paste in the screen and enters
and this process should go on till the last cell found with Data.



```
Sub macro_22333()

Dim excelApp As Object
Dim z As Integer
Set excelApp = GetObject(, "Excel.Application")
Set excelApp = GetObject("C:\Documents and Settings\mintezar\Desktop\Book1.xlsx")
z = excelApp.ActiveSheet.Range("B2").Copy
    With Session
        .WaitForEvent rcEnterPos, "30", "0", 1, 1
        .TransmitTerminalKey rcIBMPf9Key
        .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
        .WaitForEvent rcEnterPos, "30", "0", 5, 13
        .WaitForDisplayString "==>", "30", 5, 9
        .TransmitANSI "1"
        .TransmitTerminalKey rcIBMEnterKey
        .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
        .WaitForEvent rcEnterPos, "30", "0", 18, 33
        .WaitForDisplayString "ID:", "30", 18, 29
        .TransmitANSI "akhimki"
        .TransmitTerminalKey rcIBMTabKey

        ' Provide Password for Security
        Dim hostpassword As String
        hostpassword = ""
        hostpassword = .GetPassword("PASSWORD:", "", "", "")
        .TransmitANSI hostpassword
        .TransmitANSI "50.7.13"
        .TransmitTerminalKey rcIBMEnterKey
End With
    With Session
        .WaitForEvent rcEnterPos, "30", "0", 4, 16
        .WaitForDisplayString "CITY/SITE:", "30", 4, 4
        .TransmitTerminalKey rcIBMTabKey
        .TransmitTerminalKey rcIBMTabKey
        .Paste
        TransmitTerminalKey rcIBMTabKey
        .WaitForEvent rcEnterPos, "30", "0", 23, 15
        .WaitForDisplayString "SCREEN:", "30", 23, 7
        .TransmitTerminalKey rcIBMEnterKey
        .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
        .WaitForEvent rcEnterPos, "30", "0", 1, 80
        .WaitForDisplayString "UPDATE(Y/N):", "30", 1, 67
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
        .TransmitTerminalKey rcIBMNewLineKey
End With
z = excelApp.ActiveSheet.Range("C2").Copy
    With Session
        .WaitForEvent rcEnterPos, "30", "0", 4, 11
        .WaitForDisplayString "SEALS..:", "30", 4, 2
        .Paste
        .TransmitTerminalKey rcIBMEnterKey
        .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
z = excelApp.ActiveSheet.Range("b3").Copy
    With Session
        .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
        .WaitForEvent rcEnterPos, "30", "0", 3, 11
        .WaitForDisplayString "NBR:", "30", 3, 6
        .Paste
        .TransmitTerminalKey rcIBMEnterKey
        .WaitForEvent rcEnterPos, "30", "0", 1, 80
        .WaitForDisplayString "UPDATE(Y/N):", "30", 1, 67
        .MoveCursor 4, 11
        .WaitForDisplayString "SEALS..:", "30", 4, 2
z = excelApp.ActiveSheet.Range("C3").Copy
        .Paste
        .TransmitTerminalKey rcIBMEnterKey
z = excelApp.ActiveSheet.Range("B4").Copy
        .Paste
        .TransmitTerminalKey rcIBMEnterKey
        .WaitForEvent rcEnterPos, "30", "0", 1, 80
        .WaitForDisplayString "UPDATE(Y/N):", "30", 1, 67
        .MoveCursor 4, 11
        .WaitForDisplayString "SEALS..:", "30", 4, 2
        
        
End With
End With
End Sub
```


----------



## xcruc1at3r (May 30, 2012)

this is the link of the reflection Screens step by step !

 https://docs.google.com/spreadsheet/ccc?key=0Ah3qQ3ZqPOsPdHhlckhsdmctbXIybmhVVkJQZ2VfSWc


----------



## schielrn (May 31, 2012)

Get rid of the copy and paste:

Instead of:

```
.WaitForDisplayString "SEALS..:", "30", 4, 2
z = excelApp.ActiveSheet.Range("C3").Copy
        .Paste
        .TransmitTerminalKey rcIBMEnterKey
```
Use:


```
.WaitForDisplayString "SEALS..:", "30", 4, 2        
        .TransmitANSI excelApp.ActiveSheet.Range("C3").value
        .TransmitTerminalKey rcIBMEnterKey
```
Not sure if you need to specify the workbook or not because as you can see from my code I also specify the workbook. I'm not really sure what the loop would look like because it doesn't appear that it goes down a column as you have it going from C2 to B3 to C3 to B4. Unless it is suppose to go in that order and the next woulf be C4 and B5?

If that is the case then you could do something like:


```
for i = 2 to excelApp.ActiveSheet.cells(rows.count,"C").end(xlup).row
with session
        .WaitForEvent rcEnterPos, "30", "0", 1, 80
        .WaitForDisplayString "UPDATE(Y/N):", "30", 1, 67
        .MoveCursor 4, 11
        .WaitForDisplayString "SEALS..:", "30", 4, 2
        .TransmitANSI excelApp.ActiveSheet.Range("C" & i).value
        .TransmitTerminalKey rcIBMEnterKey
        .WaitForEvent rcEnterPos, "30", "0", 1, 80
        .WaitForDisplayString "UPDATE(Y/N):", "30", 1, 67
        .MoveCursor 4, 11
        .WaitForDisplayString "SEALS..:", "30", 4, 2
        .TransmitANSI excelApp.ActiveSheet.Range("B" & i+1).value
        .Paste
        .TransmitTerminalKey rcIBMEnterKey
end with
next i
```
 
Hopefully that makes some sense to you. If the copy and paste is working, then you can still use the loop as I have shown, but I would rather just input the value as opposed to copying and pasting.


----------



## schielrn (May 31, 2012)

I didn't see anything in the links that showed the step by step screens.  Also I didn't see the B2 part at the beginning, but hopefully you can build from what I have given you and just not use the +1 as I was in the loop.


----------



## xcruc1at3r (May 31, 2012)

Dam that Goc.Doc its not uploading the SnapShots (..and from office we dont have permission to use any other site for loading....( if you would give me your email address so i'd email it to you...
my data range format in Excel 
   ...Container No.                Seal No.
APZU4626368          APA9919941
TRLU3853663        APA9910157
AMFU8833877          APA9910144
APHU6188231           APA9910126
TCLU8618708           APA9907850   this is how the data order is...
start from B2 goes to C2
then B3 goes to C3
And then B4 goes to C4 and so on....till the Last found data


----------



## broberg (Jun 1, 2012)

I have done som coding along the lines of this, only I call Reflection from Excel as I find that controlling Reflection through Excel easier than the other way around.

I just wanted to give a little code, that may be able to make it a bit easier to write to reflection. The following functionis what I use to transmit text. Bear in mind that It's copied from within my broker class in Excel, but I reckon it all works in you change the "MySession" to "Session"


```
'---------------------------------------------------------------------------------------
' Procedure : TransmitText
' Author    : Morten Broberg Kristensen
' Date      : 17.01.2011
' Purpose   : Send text to the host, either to a specified location or to where the
'             cursor might be. Optional TextLength, and also it will truncate to fieldlen
'---------------------------------------------------------------------------------------
Public Function TransmitText(ByVal text As String, Optional Row As Long, Optional Column As Long, Optional TextLength As Long)

    Dim fieldLen As Long
    
   On Error GoTo TransmitText_Error

    If Not Row = 0 Then 'If we give it a row then first move the cursor!
        MySession.MoveCursor Row, Column
        MySession.WaitForEvent rcKbdEnabled, "30", "0", 1, 1 'Wait 30 sec for keyboard or time out
        MySession.TransmitTerminalKey rcIBMEraseEOFKey 'Clear field
        MySession.WaitForEvent rcKbdEnabled, "30", "0", 1, 1 'Wait 30 sec for keyboard or time out
    End If
    
    MySession.FindField CursorRow, CursorColumn, rcCurrent, rcAnyField  'Find any field in current field specified by cursorrow and cursorcol and set the properties
    fieldLen = MySession.FoundFieldLength 'Get the foundfieldlength property and use that as amount of chars to retrieve, ie. the full length of the field.
    
    
    
    If Not TextLength = 0 Then 'If textlengh is set then
        text = VBA.Left$(text, Min(TextLength, fieldLen)) 'Truncate text by the lesser of the lengths
    Else
        text = VBA.Left$(text, fieldLen) 'If textlength is not set then truncate by fieldlength
    End If
    
    'And then just send the text
    MySession.TransmitANSI text
    MySession.WaitForEvent rcKbdEnabled, "30", "0", 1, 1 'Wait 30 sec for keyboard or time out

   On Error GoTo 0
   Exit Function

TransmitText_Error:

  Err.Raise Err.Number, "@[Parser.TransmitText] " & Err.Source, Err.Description

    
    
End Function
```

Afterwards you can just call the function by calling the function


```
TransmitText("This is a testTxt",4,10)
```

And it will do the cursor moving and waiting for keyboard enabled etc. 
It will remove any text allready entered in the field, start the text in the start-location of the field belonging to the position you pass.
And finally it will truncate the text if neccesary as to not write to the next field. 

Use it if you want


----------



## xcruc1at3r (Jun 1, 2012)

i replaced MySession with Session &
i tried to use the code in excel but its asking for Sub () and if i give it a sub () so it asks for end sub as well !!... (


----------



## broberg (Jun 4, 2012)

Hi again

First off, you need to include the calling command in a sub, ie. 


```
Sub TestTransmit()
      TransmitText("This is a testTxt",4,10)
End sub
```

Also if you want to use it from within Excel, you will need to setup a reference first, and then Dim the Session

The library you shoud reference is the "WRQ Reflection for IBM 12.0 Object Library", filename : R8ole32.olb.

If you reference it I would suggest you keep the naming of MySession, and then create a new Session object with the following code.


```
Dim MySession As Reflection.Session 
Set MySession = new Session
```

I have centralized all of this code in a class object that handles all my different functions and then all I need is to instantialize this class-object.

Hope this didn't confuse you more than before?


----------



## Robertson1995 (Apr 22, 2009)

I have the following code that I use in WRQ Reflections. It is very basic and runs the command bts_status mc800bts877. The characters "877" which are in red below is a site # which changes. What I need is for the macro to run the command bts_status mc800bts and then have an inputbox ask for the next 3 characters (in this example 877) that then carriage return after ok is selected on the input box. Thanks.


Sub Macro1()
' Generated by the Reflection Macro Recorder on 04-22-2009 09:01:25.57.
' Generated by Reflection for UNIX and Digital 8.0.6.
    On Error GoTo ErrorHandler
    Const NEVER_TIME_OUT = 0
    Dim CR As String    ' Chr$(rcCR) = Chr$(13) = Control-M
    Dim ESC As String   ' Chr$(rcESC) = Chr$(27) = Control-[
    CR = Chr$(rcCR)
    ESC = Chr$(rcESC)
    With Session
        .Transmit "bts_status mc800bts877" & CR
        ' .WaitForString ESC & "[K", NEVER_TIME_OUT, rcAllowKeystrokes
    Exit Sub
ErrorHandler:
    .MsgBox Err.Description, vbExclamation + vbOKOnly
    End With
    ' Recording stopped at 09:04:44.83.
End Sub


----------



## xcruc1at3r (Jun 6, 2012)

i added 
this :

```
Sub TestTransmit()     
TransmitText("This is a testTxt",4,10) 
End sub
```
but it is showing error saying expected = 
then  i replaced  did this 

```
TransmitText.Movecursor , 4, 10
```
still showing error


----------



## xcruc1at3r (Jun 14, 2012)

well i got confused bro and was thinking over it !! but still havent reached any where!!


----------



## broberg (Jun 15, 2012)

Oh sorry I forgot that when calling a function like that you write


```
TransmitText "Test", 4,10
```

Are thgere any other errors you are getting? If so, which?


----------



## xcruc1at3r (Jun 18, 2012)

can you pls compile the complete coding! i'd be really glad bro


----------



## xcruc1at3r (Jun 18, 2012)

well i have place your coding like give below but! when i run TestTransmit it gives error that After End Sub or end Function only comment should appear ! not running


```
Sub TestTransmit()
      TransmitText "Test", 4, 10
End Sub
Dim MySession As Reflection.Session
Set MySession = New Session

'---------------------------------------------------------------------------------------
' Procedure : TransmitText
' Author    : Morten Broberg Kristensen
' Date      : 17.01.2011
' Purpose   : Send text to the host, either to a specified location or to where the
'             cursor might be. Optional TextLength, and also it will truncate to fieldlen
'---------------------------------------------------------------------------------------
Public Function TransmitText(ByVal text As String, Optional Row As Long, Optional Column As Long, Optional TextLength As Long)

    Dim fieldLen As Long
    
   On Error GoTo TransmitText_Error

    If Not Row = 0 Then 'If we give it a row then first move the cursor!
        MySession.Movecursor Row, Column
        MySession.WaitForEvent rcKbdEnabled, "30", "0", 1, 1 'Wait 30 sec for keyboard or time out
        MySession.TransmitTerminalKey rcIBMEraseEOFKey 'Clear field
        MySession.WaitForEvent rcKbdEnabled, "30", "0", 1, 1 'Wait 30 sec for keyboard or time out
    End If
    
    MySession.FindField CursorRow, CursorColumn, rcCurrent, rcAnyField  'Find any field in current field specified by cursorrow and cursorcol and set the properties
    fieldLen = MySession.FoundFieldLength 'Get the foundfieldlength property and use that as amount of chars to retrieve, ie. the full length of the field.
    
    
    
    If Not TextLength = 0 Then 'If textlengh is set then
        text = VBA.Left$(text, Min(TextLength, fieldLen)) 'Truncate text by the lesser of the lengths
    Else
        text = VBA.Left$(text, fieldLen) 'If textlength is not set then truncate by fieldlength
    End If
    
    'And then just send the text
    MySession.TransmitANSI text
    MySession.WaitForEvent rcKbdEnabled, "30", "0", 1, 1 'Wait 30 sec for keyboard or time out

   On Error GoTo 0
   Exit Function

TransmitText_Error:

  Err.Raise Err.Number, "@[Parser.TransmitText] " & Err.Source, Err.Description

    
    
End Function
End Sub
```


----------



## broberg (Jun 18, 2012)

The error you are getting basically means that you are executing code outside of a sub or function. And from the looks of your postings, it indicates the following lines

Dim MySession As Reflection.Session
Set MySession = New Session

Try moving these to right after the following line

    Dim fieldLen As Long


----------



## xcruc1at3r (Jun 18, 2012)

moves 
Dim MySession As Reflection.Session
Set MySession = New Session
right after 
 Dim fieldLen As Long like this :

Dim fieldLen As Long
    Dim MySession As Reflection.Session
Set MySession = New Session

but it is stopping at & compile error : user-defined type not defined
Public Function TransmitText(ByVal text As String, Optional Row As Long, Optional Column As Long, Optional TextLength As Long)
Dim MySession As Reflection.Session


----------



## broberg (Jun 19, 2012)

Hi again

The error you are getting is likely because you are missing the reference from post #20.

"WRQ Reflection for IBM 12.0 Object Library" or "Reflection for IBM Session", filename : R8ole32.olb.

Try to find this by, clicking "Tools -> References" and then find that reference on the list.

Also I have noticed that I am using a Minimum function in my code, so in case you don't have one of those lying around, here's an example



```
Public Function Min(ByVal num1 As Variant, ByVal num2 As Variant) As Variant
On Error GoTo ErrHandler:


    If num1 < num2 Then
        Min = num1
    Else
        Min = num2
    End If
    
Exit Function
ErrHandler:
    MsgBox "Something went wrong"
End Function
```


Also a last error in your code is the last end Sub after the end function.

Subs and function must be enclosed like following

Function FunctionName
  ...Do fancy stuff
End function

Sub SubroutineName
 ... Do sneaky stuff
End sub

Hell I'll just include the whole module here, I was also missing the code to catch the correct connection running(also I wasn't cleaning up), anyways, try the following code


```
Sub TestTransmit()
      TransmitText "Tyst2", 22, 16
End Sub




'---------------------------------------------------------------------------------------
' Procedure : TransmitText
' Author    : Morten Broberg Kristensen
' Date      : 17.01.2011
' Purpose   : Send text to the host, either to a specified location or to where the
'             cursor might be. Optional TextLength, and also it will truncate to fieldlen
'---------------------------------------------------------------------------------------
Public Function TransmitText(ByVal text As String, Optional Row As Long, Optional Column As Long, Optional TextLength As Long)


    Dim fieldLen As Long
    Dim MySession As Reflection.Session
    Set MySession = GetObject("RIBM")
    
   On Error GoTo TransmitText_Error


    If Not Row = 0 Then 'If we give it a row then first move the cursor!
        MySession.Movecursor Row, Column
        MySession.WaitForEvent rcKbdEnabled, "30", "0", 1, 1 'Wait 30 sec for keyboard or time out
        MySession.TransmitTerminalKey rcIBMEraseEOFKey 'Clear field
        MySession.WaitForEvent rcKbdEnabled, "30", "0", 1, 1 'Wait 30 sec for keyboard or time out
    End If
    
    MySession.FindField CursorRow, CursorColumn, rcCurrent, rcAnyField  'Find any field in current field specified by cursorrow and cursorcol and set the properties
    fieldLen = MySession.FoundFieldLength 'Get the foundfieldlength property and use that as amount of chars to retrieve, ie. the full length of the field.
    
    
    
    If Not TextLength = 0 Then 'If textlengh is set then
        text = VBA.Left$(text, Min(TextLength, fieldLen)) 'Truncate text by the lesser of the lengths
    Else
        text = VBA.Left$(text, fieldLen) 'If textlength is not set then truncate by fieldlength
    End If
    
    'And then just send the text
    MySession.TransmitANSI text
    MySession.WaitForEvent rcKbdEnabled, "30", "0", 1, 1 'Wait 30 sec for keyboard or time out


   Set MySession = Nothing
   On Error GoTo 0
   Exit Function


TransmitText_Error:


  Err.Raise Err.Number, "@[Parser.TransmitText] " & Err.Source, Err.Description


    
    
End Function




Public Function Min(ByVal num1 As Variant, ByVal num2 As Variant) As Variant
On Error GoTo ErrHandler:


    If num1 < num2 Then
        Min = num1
    Else
        Min = num2
    End If
    
Exit Function
ErrHandler:
    Debug.Print "Sommat went wrong"
End Function
```


----------



## xcruc1at3r (Jun 19, 2012)

i found R8ole32.olb. reference and have added it from VB tool reference & I have changed 

 TransmitText "Tyst2", 22, 16 to TransmitText "Tyst2", 5, 72 because this is the cursor location where F9 is but its not transmitting F9
so that it can move to the next screen
it gives Run-time error '4087'
application defined or object defined error


----------



## broberg (Jun 20, 2012)

Oh are you trying to transmit the Function-button F9?

My function above is only to send text across, in the test case above it is sending the text "Tyst2" (was supposed to be test, but i mistyped) to the location row 5, column 72.

Here's another function you can throw below the TrasmitText function


```
'---------------------------------------------------------------------------------------
' Procedure : SendTerminalKey
' Author    : Morten Broberg Kristensen
' Date      : 15.09.2010
' Purpose   : Will try to send the corresponding rc terminalkey
'---------------------------------------------------------------------------------------
Public Function SendTerminalKey(ByVal k As Long) As Boolean
    
   On Error GoTo SendTerminalKey_Error


    MySession.TransmitTerminalKey k
    MySession.WaitForEvent rcKbdEnabled, "30", "0", 1, 1 'Try to wait for enabled keyboard before we continue




' The code outcommented below is just used internally in my code to count amount of transaction used, and the up'n'down keys are "free" on my system
'    Select Case k
'        Case rcIBMPf7Key 
'        
'        Case rcIBMPf8Key
'        
'        Case Else
'            Transactions = Transactions + 1 'increment the trans-counter
'    End Select
    
   On Error GoTo 0
   Exit Function


SendTerminalKey_Error:


    [LEFT][COLOR=#3E3E3E]Err.Raise Err.Number, "@[Parser.[/COLOR]SendTerminalKey[COLOR=#3E3E3E]] " & Err.Source, Err.Description[/COLOR][/LEFT]
    
    
End Function
```


With these two functions you can do the following

```
[COLOR=#3E3E3E]TransmitText "Test2", 22, 16 'Sending the text "Test2" to the screen
[/COLOR]SendTerminalKey rcIBMpf9Key 'Send the Terminal key corresponding to F9
```


----------



## Robertson1995 (Apr 22, 2009)

I have the following code that I use in WRQ Reflections. It is very basic and runs the command bts_status mc800bts877. The characters "877" which are in red below is a site # which changes. What I need is for the macro to run the command bts_status mc800bts and then have an inputbox ask for the next 3 characters (in this example 877) that then carriage return after ok is selected on the input box. Thanks.


Sub Macro1()
' Generated by the Reflection Macro Recorder on 04-22-2009 09:01:25.57.
' Generated by Reflection for UNIX and Digital 8.0.6.
    On Error GoTo ErrorHandler
    Const NEVER_TIME_OUT = 0
    Dim CR As String    ' Chr$(rcCR) = Chr$(13) = Control-M
    Dim ESC As String   ' Chr$(rcESC) = Chr$(27) = Control-[
    CR = Chr$(rcCR)
    ESC = Chr$(rcESC)
    With Session
        .Transmit "bts_status mc800bts877" & CR
        ' .WaitForString ESC & "[K", NEVER_TIME_OUT, rcAllowKeystrokes
    Exit Sub
ErrorHandler:
    .MsgBox Err.Description, vbExclamation + vbOKOnly
    End With
    ' Recording stopped at 09:04:44.83.
End Sub


----------



## xcruc1at3r (Jun 20, 2012)

let me tell you the complete procedure 
1st of reflection is already opened and connected with the Host ip and on the other hand we have Excel
need to run macro in excel so that Reflection can be linked with Excel and
1 step : Transmit f9 key
2 : 
        .WaitForEvent rcEnterPos, "30", "0", 1, 1
        .TransmitTerminalKey rcIBMPf9Key
        .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
        .WaitForEvent rcEnterPos, "30", "0", 5, 13
        .WaitForDisplayString "==>", "30", 5, 9
        .TransmitANSI "1"
        .TransmitTerminalKey rcIBMEnterKey
        .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
        .WaitForEvent rcEnterPos, "30", "0", 18, 33
        .WaitForDisplayString "ID:", "30", 18, 29
        .TransmitANSI "user id"
        .TransmitTerminalKey rcIBMTabKey

        ' Password has not been recorded for security
        Dim hostpassword As String
        hostpassword = ""
        hostpassword = .GetPassword("PASSWORD:", "", "", "")
        .TransmitANSI hostpassword
        .TransmitANSI "50.7.13"
        .TransmitTerminalKey rcIBMEnterKey

And then Get data from excel and paste in REflection


----------



## broberg (Jun 21, 2012)

Let me try to explain what your recorded code does.


.WaitForEvent rcEnterPos, "30", "0", 1, 1Make the client wait a maximum of 30 seconds for the cursor to reach row 1, column 1.TransmitTerminalKey rcIBMPf9KeyTransmit the F9 button to the client.WaitForEvent rcKbdEnabled, "30", "0", 1, 1Wait max 30 seconds, for the keyboard to be enabled to the user again. It locks the keyboard while it "thinks".WaitForEvent rcEnterPos, "30", "0", 5, 13Wait max 30 sec for cursor to enter pos 5, 13.WaitForDisplayString "==>", "30", 5, 9Wait max 30 secs for the string "==>" to appear at location 5,9.TransmitANSI "1"Send the text "1".TransmitTerminalKey rcIBMEnterKeyTransmit the ENTER button.WaitForEvent rcKbdEnabled, "30", "0", 1, 1Wait max 30 secs for the keyboard to be enabled.WaitForEvent rcEnterPos, "30", "0", 18, 33Wait max 30 secs for the cursor to enter position 18,33.WaitForDisplayString "ID:", "30", 18, 29Wait max 30 secs for the string "ID:" to appear at location 18,29.TransmitANSI "user id"Send text "user id" to the client.TransmitTerminalKey rcIBMTabKeySend TAB key to the client

A lot of these lines of code can be avoided. As you see in my functions, they have build in waiting.

So what you could cook the above down to is


```
SendTerminalKey [COLOR=#574123]rcIBMPf9Key 'Send F9 key
' You could insert a codeline here to check for the string "==>" if you'd like. I use loads of checks to check for the correct panels
TransmitText "1", 5, 13
SendTerminalKey [/COLOR][COLOR=#574123]rcIBMEnterKey
TransmitText "user id", 18, 33[/COLOR]
```

Does that help you in any way?


----------



## xcruc1at3r (Jun 21, 2012)

The description is good addition to my knowledge 
well can you check whats is wrong with below given code ? It Opens Reflection from Excel But does not Transmit f9 key and Stops

```
Sub CreateReflectionObject()
    Dim Ribm As Object
    Set Ribm = CreateObject("ReflectionIBM.Session")
    Ribm.Visible = True
    With Ribm
        .opensettings 1, "C:\Documents and Settings\Desktop\APL.rsf"
        .WaitForEvent rcEnterPos, "30", "0", 1, 1
        .TransmitTerminalKey rcIBMPf9Key
        .WaitForEvent rcKbdEnabled, "30", "1", 1, 1
        .WaitForEvent rcEnterPos, "30", "0", 1, 1
        .TransmitTerminalKey rcIBMPf9Key
        .WaitForEvent rcEnterPos, "30", "0", 5, 26
        .TransmitANSI "1"
        .TransmitTerminalKey rcIBMEnterKey
        .WaitForEvent rcKbdEnabled, "30", "0", 1, 1
        .WaitForEvent rcEnterPos, "30", "0", 18, 33
        .WaitForDisplayString "ID:", "30", 18, 29
        .TransmitANSI "AKHIAAK"
        .TransmitTerminalKey rcIBMTabKey

        ' Password has not been recorded for security
        Dim hostpassword As String
        hostpassword = ""
        hostpassword = .GetPassword("PASSWORD:", "", "", "")
        .TransmitANSI hostpassword
        .TransmitANSI "50.13.9"
        .TransmitTerminalKey rcIBMEnterKey
    End With
    End
End Sub
```

above code is the 1st paste if it executes successfully  so after that need to copy data from excel and paste in reflection


----------



## xcruc1at3r (Jun 25, 2012)

is there anyways to attach excel attachment ? in this forum ? so tat you can get the better picture


----------



## xcruc1at3r (Jul 3, 2012)

broberg said:


> Let me try to explain what your recorded code does.
> 
> 
> ```
> ...



well F9 Key is not being executed what is the solution for it...bro


----------



## broberg (Jul 3, 2012)

Hmm... Might be that the MySession object was not instantiated for the SendTerminalKey function.

I have included the full code below and executed it (so it should work now), can you try this version?

I have made my own broker in a class, so I only have to instantiate that class and then it handles it all for me. IMO thats the best solution as I can take that class and export it to other projects and I know that I got all the functions setup as I want them.


```
Sub TestTransmit()
    TransmitText "Test2", 22, 16 'Sending the text "Test2" to the screen
    SendTerminalKey rcIBMpf9Key 'Send the Terminal key corresponding to F9
End Sub








'---------------------------------------------------------------------------------------
' Procedure : TransmitText
' Author    : Morten Broberg Kristensen
' Date      : 17.01.2011
' Purpose   : Send text to the host, either to a specified location or to where the
'             cursor might be. Optional TextLength, and also it will truncate to fieldlen
'---------------------------------------------------------------------------------------
Public Function TransmitText(ByVal text As String, Optional Row As Long, Optional Column As Long, Optional TextLength As Long)




    Dim fieldLen As Long
    Dim MySession As Reflection.Session
    Set MySession = GetObject("RIBM")
    
   On Error GoTo TransmitText_Error




    If Not Row = 0 Then 'If we give it a row then first move the cursor!
        MySession.Movecursor Row, Column
        MySession.WaitForEvent rcKbdEnabled, "30", "0", 1, 1 'Wait 30 sec for keyboard or time out
        MySession.TransmitTerminalKey rcIBMEraseEOFKey 'Clear field
        MySession.WaitForEvent rcKbdEnabled, "30", "0", 1, 1 'Wait 30 sec for keyboard or time out
    End If
    
    MySession.FindField CursorRow, CursorColumn, rcCurrent, rcAnyField  'Find any field in current field specified by cursorrow and cursorcol and set the properties
    fieldLen = MySession.FoundFieldLength 'Get the foundfieldlength property and use that as amount of chars to retrieve, ie. the full length of the field.
    
    
    
    If Not TextLength = 0 Then 'If textlengh is set then
        text = VBA.Left$(text, Min(TextLength, fieldLen)) 'Truncate text by the lesser of the lengths
    Else
        text = VBA.Left$(text, fieldLen) 'If textlength is not set then truncate by fieldlength
    End If
    
    'And then just send the text
    MySession.TransmitANSI text
    MySession.WaitForEvent rcKbdEnabled, "30", "0", 1, 1 'Wait 30 sec for keyboard or time out




   Set MySession = Nothing
   On Error GoTo 0
   Exit Function




TransmitText_Error:




  Err.Raise Err.Number, "@[Parser.TransmitText] " & Err.Source, Err.Description




    
    
End Function








Public Function Min(ByVal num1 As Variant, ByVal num2 As Variant) As Variant
On Error GoTo ErrHandler:




    If num1 < num2 Then
        Min = num1
    Else
        Min = num2
    End If
    
Exit Function
ErrHandler:
    Debug.Print "Sommat went wrong"
End Function


'---------------------------------------------------------------------------------------
' Procedure : SendTerminalKey
' Author    : Morten Broberg Kristensen
' Date      : 15.09.2010
' Purpose   : Will try to send the corresponding rc terminalkey
'---------------------------------------------------------------------------------------
Public Function SendTerminalKey(ByVal k As Long) As Boolean
    
   On Error GoTo SendTerminalKey_Error
    
    Dim MySession As Reflection.Session
    Set MySession = GetObject("RIBM")


    MySession.TransmitTerminalKey k
    MySession.WaitForEvent rcKbdEnabled, "30", "0", 1, 1 'Try to wait for enabled keyboard before we continue








' The code outcommented below is just used internally in my code to count amount of transaction used, and the up'n'down keys are "free" on my system
'    Select Case k
'        Case rcIBMPf7Key
'
'        Case rcIBMPf8Key
'
'        Case Else
'            Transactions = Transactions + 1 'increment the trans-counter
'    End Select
    
   Set MySession = Nothing
   On Error GoTo 0
   Exit Function




SendTerminalKey_Error:




    
Err.Raise Err.Number, "@[Parser.SendTerminalKey] " & Err.Source, Err.Description
    
    
End Function
```


----------



## xcruc1at3r (Jul 9, 2012)

I have added Added the 

```
Sub TestTransmit()
       SendTerminalKey rcIBMPf9Key 'Send the Terminal key corresponding to F9
End Sub
```

And the Transmist Function Code in 
VBA Mode and when Reflection is Opened and i Run Set Transmit Macro it Successfully Executes the f9 key  and am really gald thanks to you...but the issue i want Excel to Open Reflection which is located on the Desktop

MySession.opensettings 1, "C:\Documents and Settings\mintezar\Desktop\APL.rsf"

 so that it can open from excel and gets connected and then executes the f9 ki and the moves towards the ID and password screen ...
could it be done!...
with your help alot of things are getting cleared


----------



## broberg (Jul 9, 2012)

Great, so we are getting closer.

Now look at the code i wrote, the following code captures a running instance of Reflection

```
[LEFT][COLOR=#333333]Set MySession = GetObject("RIBM")[/COLOR][/LEFT]
```

But what we are after is actually to create an new instance, and therefore we instead need the following.

```
Set MySession = CreateObject("ReflectionIBM.Session")
```

This will create a hidden instance of reflection, you can choose to show it with 
	
	
	
	
	
	



```
MySession.Visible = True
```
. Afterthis you can load the settingsfile and the use the Myssesion.connect method to connect to the machine.

I would though advice you to move this to a class object instead as to more easily maintain the object. This is because you should only keep one session running, and will have to change my supplied functions to either expect a session object as variable or define a global object somewhere. Therefore a class object would seem more appropriate (also if you want to reuse it in other projects)

I would define the MySession object as a global object for the whole class, and then use the class initializing/termination functions to setup the objectes, and then add a function as to connect it.

Does this make any sense to you?


----------



## broberg (Jul 9, 2012)

Just to get you started, I've written the following code

To see how this works, right-click the Project in the Project-explorer and choose "Insert" -> "Class module"
Click the class file, prob. called "Class1" and press F4 to get to properties. Change the name to "ReflectionClass" and set the instancing to Private. Afterwards copy the following code to that file.


```
Dim MySession As Reflection.Session 'This object is used throughout the whole class




Private Sub Class_Initialize()
    Set MySession = CreateObject("ReflectionIBM.Session")
End Sub


Private Sub Class_Terminate()
    Set MySession = Nothing
End Sub




Public Sub Connect()
    MySession.Visible = True
    MySession.OpenSettings 1, "Z:\Programming\Reflection Dev\tmp.rsf" 'Change this to your settingsfile
    
    If MySession.Connected = False Then MySession.Connect
    
End Sub
'---------------------------------------------------------------------------------------
' Procedure : TransmitText
' Author    : Morten Broberg Kristensen
' Date      : 17.01.2011
' Purpose   : Send text to the host, either to a specified location or to where the
'             cursor might be. Optional TextLength, and also it will truncate to fieldlen
'---------------------------------------------------------------------------------------
Public Function TransmitText(ByVal text As String, Optional Row As Long, Optional Column As Long, Optional TextLength As Long)




    Dim fieldLen As Long


    
   On Error GoTo TransmitText_Error




    If Not Row = 0 Then 'If we give it a row then first move the cursor!
        MySession.Movecursor Row, Column
        MySession.WaitForEvent rcKbdEnabled, "30", "0", 1, 1 'Wait 30 sec for keyboard or time out
        MySession.TransmitTerminalKey rcIBMEraseEOFKey 'Clear field
        MySession.WaitForEvent rcKbdEnabled, "30", "0", 1, 1 'Wait 30 sec for keyboard or time out
    End If
    
    MySession.FindField CursorRow, CursorColumn, rcCurrent, rcAnyField  'Find any field in current field specified by cursorrow and cursorcol and set the properties
    fieldLen = MySession.FoundFieldLength 'Get the foundfieldlength property and use that as amount of chars to retrieve, ie. the full length of the field.
    
    
    
    If Not TextLength = 0 Then 'If textlengh is set then
        text = VBA.Left$(text, Min(TextLength, fieldLen)) 'Truncate text by the lesser of the lengths
    Else
        text = VBA.Left$(text, fieldLen) 'If textlength is not set then truncate by fieldlength
    End If
    
    'And then just send the text
    MySession.TransmitANSI text
    MySession.WaitForEvent rcKbdEnabled, "30", "0", 1, 1 'Wait 30 sec for keyboard or time out






   On Error GoTo 0
   Exit Function




TransmitText_Error:




  Err.Raise Err.Number, "@[Parser.TransmitText] " & Err.Source, Err.Description




    
    
End Function








Public Function Min(ByVal num1 As Variant, ByVal num2 As Variant) As Variant
On Error GoTo ErrHandler:




    If num1 < num2 Then
        Min = num1
    Else
        Min = num2
    End If
    
Exit Function
ErrHandler:
    Debug.Print "Sommat went wrong"
End Function


'---------------------------------------------------------------------------------------
' Procedure : SendTerminalKey
' Author    : Morten Broberg Kristensen
' Date      : 15.09.2010
' Purpose   : Will try to send the corresponding rc terminalkey
'---------------------------------------------------------------------------------------
Public Function SendTerminalKey(ByVal k As Long) As Boolean
    
   On Error GoTo SendTerminalKey_Error
    


    MySession.TransmitTerminalKey k
    MySession.WaitForEvent rcKbdEnabled, "30", "0", 1, 1 'Try to wait for enabled keyboard before we continue








' The code outcommented below is just used internally in my code to count amount of transaction used, and the up'n'down keys are "free" on my system
'    Select Case k
'        Case rcIBMPf7Key
'
'        Case rcIBMPf8Key
'
'        Case Else
'            Transactions = Transactions + 1 'increment the trans-counter
'    End Select
    


   On Error GoTo 0
   Exit Function




SendTerminalKey_Error:




    
Err.Raise Err.Number, "@[Parser.SendTerminalKey] " & Err.Source, Err.Description
    
    
End Function
```

Still with me?

Now we got a class going and we can insert the following in any module


```
Sub TestOwnClass()    Dim myReflection As ReflectionClass
    Set myReflection = New ReflectionClass
    
    myReflection.Connect
    set myReflection = Nothing
End Sub
```

See what we did? We moved all the logic to our class, in which we only got one MySession in total, and that Session is shared among the other classes. When we run the connect command on our own class, it loads the settingsfile and connects (you can chose to show or hide it in there if you want).

You can now use our newly create object myReflection with the public functions in our class, ie. TransmitText and SendTerminalKey in the following manner 
myReflection.SendTerminalKey and myReflection.TransmitText. Also If you need to keep expanding to other projects etc. you can just export this class and use it again.

Just for reference, the line "Set myReflection = New ReflectionClass" executes the function Class_Initialize() in our class, and "set myReflection = Nothing" runs  Class_Terminate() and cleans up, thats why I placed our own creation of objects in these function.

Hope this helps you further along?


----------



## xcruc1at3r (Jul 9, 2012)

am with you bro 
Step one : Class Modules Created
Step 2 : Name changed from Class1 to ReflectionClass
Step 3 : Changed instancing to Private
Step 4 Copied Code and inserted in ReflectionClass

Well bro TransmitTex "Test2", 22, 16 Is Is not of any use!...cause if f9 key is executing directly  like this 

```
Sub TestTransmit()       
SendTerminalKey rcIBMPf9Key 'Send the Terminal key corresponding to F9 
End Sub
```

so we wont be needing 22, 16 at all :D cause i was thinking that 1st we need to move to cursor to the location and then f9 key will execute but its not like that rite !!....

step 5 would be ? to add this code in Module 1 ?!!!
to Add 

```
Sub TestOwnClass()
 Dim myReflection As ReflectionClass
 Set myReflection = New ReflectionClass
myReflection.Connect
set myReflection = Nothing 
End Sub
```


trying to understand the concept behind your coding :D...


----------



## Robertson1995 (Apr 22, 2009)

I have the following code that I use in WRQ Reflections. It is very basic and runs the command bts_status mc800bts877. The characters "877" which are in red below is a site # which changes. What I need is for the macro to run the command bts_status mc800bts and then have an inputbox ask for the next 3 characters (in this example 877) that then carriage return after ok is selected on the input box. Thanks.


Sub Macro1()
' Generated by the Reflection Macro Recorder on 04-22-2009 09:01:25.57.
' Generated by Reflection for UNIX and Digital 8.0.6.
    On Error GoTo ErrorHandler
    Const NEVER_TIME_OUT = 0
    Dim CR As String    ' Chr$(rcCR) = Chr$(13) = Control-M
    Dim ESC As String   ' Chr$(rcESC) = Chr$(27) = Control-[
    CR = Chr$(rcCR)
    ESC = Chr$(rcESC)
    With Session
        .Transmit "bts_status mc800bts877" & CR
        ' .WaitForString ESC & "[K", NEVER_TIME_OUT, rcAllowKeystrokes
    Exit Sub
ErrorHandler:
    .MsgBox Err.Description, vbExclamation + vbOKOnly
    End With
    ' Recording stopped at 09:04:44.83.
End Sub


----------



## broberg (Jul 10, 2012)

Well first of, after we have created the class, we will be using that for sending text and terminalkeys.

So after we have instantiated the object, we can use it to send the text.


```
Sub TestOwnClass()
 Dim myReflection As ReflectionClass
 Set myReflection = New ReflectionClass
myReflection.Connect

myReflection.SendTerminalKey rcIBMPf9Key 'This sends our F9Key
myReflection.TransmitText "Test2", 22, 16 'This sends the text to loc 22,16


set myReflection = Nothing 
End Sub
```

Actually The function is coded so that you do not have to issue the row x column where you want to send the text, if you omit this information, it will just send it to the current cursor location. But if you do give this data, the function TransmitText will move the cursor for you. My idea is to move alle the nitty-gritty code away into the class, making it easier to code up to the class, and more readable as well. You could also easily expand the class with a new function to move the cursor, and I indeed have such a function in my own "parser"-class (well in algoritm terms, it is more like a broker-pattern class, but thats not important). But I thought it would be much better to write the class you need as my class is part of a 60.000 line project, so theres loads of functions which you will probably not have any use for.

So I guess my concepts are reuseability and abstraction. You still following?


----------



## xcruc1at3r (Aug 6, 2012)

The hard Disk got Busted ! ... well have to start all over again due to which i was not able to come online and was getting backup systems ...so Now finially i got a Dedicated System...
well what i have did till now is ...
Created Class Modules
Name changed from Class1 to ReflectionClass
Changed instancing to Private
Copied Code and inserted in ReflectionClass
&
copied the below given code and added in module 1

```
Sub TestOwnClass()
 Dim myReflection As ReflectionClass
 Set myReflection = New ReflectionClass
myReflection.Connect
myReflection.SendTerminalKey rcIBMPf9Key 'This sends our F9Key
Set myReflection = Nothing
End Sub
```
The ThisWorkBook Code Sheet is empty...

When i Execute TestOwnClass it Open Reflection and connects it automatically but is not Transmitting f9 key

So what should i do about it!..
and sorry for a delay bro...


----------



## xcruc1at3r (Aug 6, 2012)

in start when the Reflection Opens via excel and gets connected the cursor moves to the given location as in coding it gives error! cause the 1st Main Screen executes via f9 key & cursor move hangs the Screen gives this error X <- X -> 
1st step after reflection is connected f9 key should execute so that it the next screen should appear...


----------



## xcruc1at3r (Aug 11, 2012)

i have managed to upload the file for your understanding...
http://www.4shared.com/file/UcXrmQlk/Paste_Data.html?refurl=d1url

well it has the snapshots for the Reflection's screen.... with complete description


----------



## broberg (Sep 14, 2012)

Allright, lets see if I can direct you through your snapshots

First of to send a PF9, as discussed earlier you just need to use the SendTerminalKey function. so Lets say we got our class instantiated with


```
Sub TestOwnClass()
 Dim myReflection As ReflectionClass
 Set myReflection = New ReflectionClass
myReflection.Connect 'Connect to the mainframe

'THIS IS WHERE OUR BATCH CODE IS GOING TO BE

Set myReflection = Nothing
End Sub
```

So at the line in all caps you issue a


```
myReflection.SendTerminalKey rcIBMPf9Key 'This sends our F9Key
```

Afterwards it seems you are submitting the command "50.7.13" at location 23,16 (After MENU OPTION: ). The code we made earlier can du this by first submitting the text to location 23,16 and then sending Enter. So if I am getting the flow correctly you need to run this after the PF9


```
myReflection.TransmitText "50.7.13", 23, 16
    myReflection.SendTerminalKey rcIBMEnterKey
```

Then looking at your next snapshot I can see that the CTR number is entered at location 3,11 (see the lower right corner). If we say that you keep your CTR number in column A and row 1 you can find the value of this in the Cells function, ie Cells (RowIndex, ColumnIndex). So Cells(1,1) is equivalent to A1. If you then need to send another Enter the following should be sufficient


```
myReflection.TransmitText Cells(1, 1), 3, 11
    myReflection.SendTerminalKey rcIBMEnterKey
```

So then we get to the SEAL panel (and I'm allready lost  ) but I think you want to copy a value from column B to position 4,11, so lets try with


```
myReflection.TransmitText Cells(1, 2), 4, 11
    myReflection.SendTerminalKey rcIBMEnterKey
```

Thereby we copy in the text from B1 to 4,11.

So in short this is the whole code for login to one container inserted


```
myReflection.SendTerminalKey rcIBMPf9Key 'The first F9 panel
    
    
    myReflection.TransmitText "50.7.13", 23, 16 
    myReflection.SendTerminalKey rcIBMEnterKey 'Then put in 50.7.13 and send an enter key
    
    myReflection.TransmitText Cells(1, 1), 3, 11
    myReflection.SendTerminalKey rcIBMEnterKey ' Insert value of A1 and send enter
    
    myReflection.TransmitText Cells(1, 2), 4, 11
    myReflection.SendTerminalKey rcIBMEnterKey ' Insert value of B1 and send enter
```

I'm guessing you need to loop this for a list of containers, but I don't know which steps to loop, but I hope this can get you started?


----------



## xcruc1at3r (Sep 15, 2012)

1st of all thanks for your reply bro and secondly you must be getting confused cause the file that i managed to upload has 3 screen shots missing so if you can provide me with your email address so that i can upload....or for that i has to go to my cousins place so that i can upload the excel file again

yes i need a loop for a list of containers...and the range is dynamic....its not fixed!!


----------



## xcruc1at3r (Sep 15, 2012)

3 screen shots details after pressing f9 the next screen asks for a numeric key 1  and enter then the login password screen appears after entering the  login and password the cursor moves to Menu Option: we can directly  place 50.7.13 to move to the seal screen or press enter to go to menu  screen and then place 50.7.13....
i can email you the excel file bro


----------



## xcruc1at3r (Sep 16, 2012)

i have managed to upload the file 
Paste Data UPDATED.xlsx - 4shared.com - online file sharing and storage - download
its Updated and has all the screen shorts :D


----------



## xcruc1at3r (Nov 6, 2012)

well we need to Loop the container and seal phase !!..till the last seal number found in the excel sheet...as the list is dynamic


----------



## broberg (Nov 6, 2012)

Disclaimer: I'm not actually near an editor, so I cannot proof-read my code, I'm going a bit by memory 

Well the first 4 screenshots are kinda trivial by now, I'll just include them for ease of reading as they are actually quite straight forward with the functions we have allready made... 

The function SendTerminalKey is what sends F9 keys and enter, etc.
The function TransmitText sends normal text to the screen.


So To send the F9 (Screenshot 1):

```
myReflection.SendTerminalKey rcIBMPf9Key 'This sends our F9Key
```

To send the 1 and press enter (Screenshot 2):

```
myReflection.TransmitText "1", 5, 13 'Insert 1 at location 5,13
myReflection.SendTerminalKey rcIBMEnterKey 'Send the Enter key to continue
```

Inserting User and ID (Screenshot 3):

```
myReflection.TransmitText "USER", 18, 33 'Change the USER to your USER-ID
myReflection.TransmitText "PASSWORD", 18, 33 'Change the PASSWORD to your PASSWORD and also change to the correct location
myReflection.SendTerminalKey rcIBMEnterKey 'Send the Enter key to continue
```

Calling the right screen/panel (Screenshot 4):

```
myReflection.TransmitText "50.7.13", 23, 16 'Put the text 50.7.13 at the command line
myReflection.SendTerminalKey rcIBMEnterKey 'Send the Enter key to continue
```

This is where the actual fun begins... This is some pseudo-code for how I see your process:


For Each ContainerLine
	Insert ContainerNum at Location 3,11
	Send EnterKey
	Insert SealNum at Location 4,11
	Send EnterKey
Next ContainerLine

So Lets get this into some real Code, I've put the comments in after the '


```
Dim lng_ContainerIterator as long 'This is to keep track of which line in the Sheet we are processing
Dim lng_LastContainerRow as long 'This var will hold the last container row


lng_LastContainerRow = ActiveSheet.Cells(ActiveSheet.Rows.count, "A").End(xlUp).Row 'This finds the first cell with content starting from the buttom and up, should also be the last cell in a range without empty rows.




'I assume your data start at row 2 and theres columng headers in row 1
For lng_ContainerIterator = 2 to lng_LastContainerRow
	myReflection.TransmitText Cells(lng_ContainerIterator,"A"), 3, 11 'Send the content of column A in the current row to 3,11
	myReflection.SendTerminalKey rcIBMEnterKey 'Send the Enter key to continue
	myReflection.TransmitText Cells(lng_ContainerIterator,"B"), 4, 11 'Send the content of column B in the current row to 4,11
	myReflection.SendTerminalKey rcIBMEnterKey 'Send the Enter key to continue
next lng_ContainerIterator 'Do it again with the next row
```

This should loop the Container actions untill we get to the last line.

If this was my project though here's some thoughts I would prob. take into consideration



I would start the batch-program at the Insertion of the Container Num, this is so that I do not have to be at the login screen to start the program, to me this gives it a bit more flexibility, plus another co-worker could also run it, as he just need to log in and go to the right panel/screen to start it.
I would also code in some protection to ensure that I only insert text into the right panels/screens. I would use the text allready on the screen to make sure I am on the panel I expect to be on before doing anything.

Hope this can help you further along


----------



## Robertson1995 (Apr 22, 2009)

I have the following code that I use in WRQ Reflections. It is very basic and runs the command bts_status mc800bts877. The characters "877" which are in red below is a site # which changes. What I need is for the macro to run the command bts_status mc800bts and then have an inputbox ask for the next 3 characters (in this example 877) that then carriage return after ok is selected on the input box. Thanks.


Sub Macro1()
' Generated by the Reflection Macro Recorder on 04-22-2009 09:01:25.57.
' Generated by Reflection for UNIX and Digital 8.0.6.
    On Error GoTo ErrorHandler
    Const NEVER_TIME_OUT = 0
    Dim CR As String    ' Chr$(rcCR) = Chr$(13) = Control-M
    Dim ESC As String   ' Chr$(rcESC) = Chr$(27) = Control-[
    CR = Chr$(rcCR)
    ESC = Chr$(rcESC)
    With Session
        .Transmit "bts_status mc800bts877" & CR
        ' .WaitForString ESC & "[K", NEVER_TIME_OUT, rcAllowKeystrokes
    Exit Sub
ErrorHandler:
    .MsgBox Err.Description, vbExclamation + vbOKOnly
    End With
    ' Recording stopped at 09:04:44.83.
End Sub


----------



## xcruc1at3r (Nov 7, 2012)

The code would be like given below but in between it f9key is not being executed after reflection gets connected! and 1 more then we haven't mentioned the location of excel sheet from which reflection will copy the data!

```
myReflection.SendTerminalKey rcIBMPf9Key 'This sends our F9Key
```


```
Sub TestOwnClass()
Dim myReflection As ReflectionClass
    Set myReflection = New ReflectionClass
    
    myReflection.Connect
    myReflection.SendTerminalKey rcIBMPf9Key 'This sends our F9Key
    myReflection.TransmitText "1", 5, 13 'Insert 1 at location 5,13
    myReflection.SendTerminalKey rcIBMEnterKey 'Send the Enter key to continue
    myReflection.TransmitText "USER", 18, 33 'Change the USER to your USER-ID
    myReflection.TransmitText "PASSWORD", 18, 33 'Change the PASSWORD to your PASSWORD and also change to the correct location
    myReflection.SendTerminalKey rcIBMEnterKey 'Send the Enter key to continue
    myReflection.TransmitText "50.7.13", 23, 16 'Put the text 50.7.13 at the command line
    myReflection.SendTerminalKey rcIBMEnterKey 'Send the Enter key to continue
    Set myReflection = Nothing
End Sub
```

and  the below given will be placed in Class Modules ?

```
Dim lng_ContainerIterator as long 'This is to keep track of which line in the Sheet we are processing
Dim lng_LastContainerRow as long 'This var will hold the last container row


lng_LastContainerRow = ActiveSheet.Cells(ActiveSheet.Rows.count, "A").End(xlUp).Row 'This finds the first cell with content starting from the buttom and up, should also be the last cell in a range without empty rows.




'I assume your data start at row 2 and theres columng headers in row 1
For lng_ContainerIterator = 2 to lng_LastContainerRow
	myReflection.TransmitText Cells(lng_ContainerIterator,"A"), 3, 11 'Send the content of column A in the current row to 3,11
	myReflection.SendTerminalKey rcIBMEnterKey 'Send the Enter key to continue
	myReflection.TransmitText Cells(lng_ContainerIterator,"B"), 4, 11 'Send the content of column B in the current row to 4,11
	myReflection.SendTerminalKey rcIBMEnterKey 'Send the Enter key to continue
next lng_ContainerIterator 'Do it again with the next row
```

and in  Class Module i already have placed your given function coding 


```
Dim MySession As Reflection.Session 'This object is used throughout the whole class


Private Sub Class_Initialize()
    Set MySession = CreateObject("ReflectionIBM.Session")
End Sub

Private Sub Class_Terminate()
    Set MySession = Nothing
End Sub

Public Sub Connect()
    MySession.Visible = True
    MySession.OpenSettings 1, "C:\Documents and Settings\sshahzad\Desktop\Reflection.rsf" 'Change this to your settingsfile
    
    If MySession.Connected = False Then MySession.Connect
    
End Sub
'---------------------------------------------------------------------------------------
' Procedure : TransmitText
' Author    : Morten Broberg Kristensen
' Date      : 17.01.2011
' Purpose   : Send text to the host, either to a specified location or to where the
'             cursor might be. Optional TextLength, and also it will truncate to fieldlen
'---------------------------------------------------------------------------------------
Public Function TransmitText(ByVal text As String, Optional Row As Long, Optional Column As Long, Optional TextLength As Long)

Dim fieldLen As Long

On Error GoTo TransmitText_Error

If Not Row = 0 Then 'If we give it a row then first move the cursor!
        MySession.MoveCursor Row, Column
        MySession.WaitForEvent rcKbdEnabled, "30", "0", 1, 1 'Wait 30 sec for keyboard or time out
        MySession.TransmitTerminalKey rcIBMEraseEOFKey 'Clear field
        MySession.WaitForEvent rcKbdEnabled, "30", "0", 1, 1 'Wait 30 sec for keyboard or time out
    End If
    
    MySession.FindField CursorRow, CursorColumn, rcCurrent, rcAnyField  'Find any field in current field specified by cursorrow and cursorcol and set the properties
    fieldLen = MySession.FoundFieldLength 'Get the foundfieldlength property and use that as amount of chars to retrieve, ie. the full length of the field.
    
    If Not TextLength = 0 Then 'If textlengh is set then
        text = VBA.Left$(text, Min(TextLength, fieldLen)) 'Truncate text by the lesser of the lengths
    Else
        text = VBA.Left$(text, fieldLen) 'If textlength is not set then truncate by fieldlength
    End If
    
    'And then just send the text
    MySession.TransmitANSI text
    MySession.WaitForEvent rcKbdEnabled, "30", "0", 1, 1 'Wait 30 sec for 

keyboard or time out
On Error GoTo 0
   Exit Function

TransmitText_Error:

Err.Raise Err.Number, "@[Parser.TransmitText] " & Err.Source, Err.Description

End Function


Public Function Min(ByVal num1 As Variant, ByVal num2 As Variant) As Variant
On Error GoTo ErrHandler:

    If num1 < num2 Then
        Min = num1
    Else
        Min = num2
    End If
    
Exit Function
ErrHandler:
    Debug.Print "Sommat went wrong"
End Function

'---------------------------------------------------------------------------------------
' Procedure : SendTerminalKey
' Author    : Morten Broberg Kristensen
' Date      : 15.09.2010
' Purpose   : Will try to send the corresponding rc terminalkey
'---------------------------------------------------------------------------------------
Public Function SendTerminalKey(ByVal k As Long) As Boolean
    
   On Error GoTo SendTerminalKey_Error
    
    MySession.TransmitTerminalKey k
    MySession.WaitForEvent rcKbdEnabled, "30", "0", 1, 1 'Try to wait for enabled keyboard before we continue

' The code outcommented below is just used internally in my code to count amount of transaction used, and the up'n'down keys are "free" on my system
'    Select Case k
'        Case rcIBMPf7Key
'
'        Case rcIBMPf8Key
'
'        Case Else
'            Transactions = Transactions + 1 'increment the trans-counter
'    End Select
    
   On Error GoTo 0
   Exit Function

SendTerminalKey_Error:

Err.Raise Err.Number, "@[Parser.SendTerminalKey] " & Err.Source, Err.Description
    End Function
```


----------



## NitinShevkari (Apr 14, 2013)

hi guys i want help i want to call "terminal emulator WRQ Reflection for Unix/Digital" and open its file test.r2w through excel macro or any batch or vb scripting... is it possible to do that?


----------



## jfarc (Apr 14, 2013)

NitinShevkari said:


> hi guys i want help i want to call "terminal emulator WRQ Reflection for Unix/Digital" and open its file test.r2w through excel macro or any batch or vb scripting... is it possible to do that?



Hello & welcome to the forum,

I played around with it when I was looking for the same thing and found this to work:

```
Dim wbThis As Workbook
    Set wbThis = ThisWorkbook
    RUNWRQ = "C:\Program Files\Reflection\r2win.exe " & wbThis.Path & "\test.r2w"
    Shell RUNWRQ, vbNormalFocus
```
This is an Excel Macro.  I use the wbThis.Path so I can place the Excel workbook running the macro that calls test.r2w in the same directory path.

I don't know if there is another way.  Hopefully someone else will respond that uses a different way.


----------



## NitinShevkari (Apr 15, 2013)

hey thanks buddy little more help... actully i found one script to run excel file and its macro automatically through *.vbs script

" Sub LaunchMacro()       Dim xl
      Dim xlBook      
      Dim sCurPath


        sCurPath = CreateObject("Scripting.FileSystemObject").GetAbsolutePathName(".")
        Set xl = CreateObject("Excel.application")
        Set xlBook = xl.Workbooks.Open(sCurPath & "\mw1.xlsm", 0, True)      
        xl.Application.Visible = True
        xl.Application.run "mw1.xlsm!Macro1"
        xl.DisplayAlerts = true
        xlBook.saved = True
       xl.activewindow.close
        xl.Quit


        Set xlBook = Nothing
        Set xl = Nothing"
so is it possible to open test.r2w file and run WRQ Reflection macro automatically? 




jfarc said:


> Hello & welcome to the forum,
> 
> I played around with it when I was looking for the same thing and found this to work:
> 
> ...


----------



## jfarc (Apr 15, 2013)

NitinShevkari said:


> so is it possible to open test.r2w file and run WRQ Reflection macro automatically?



I'm not quite sure there is an Excel command line argument that will run a specific Macro inside Reflection.  But, the way I do what you want is not through Excel, but through Reflection itself.  Open your Reflection settings file and go to the Connection Setup and choose a Connection Macro, which runs whenever that settings file is opened.


----------



## NitinShevkari (Apr 15, 2013)

That is cool! thanks! i will try this 



jfarc said:


> I'm not quite sure there is an Excel command line argument that will run a specific Macro inside Reflection.  But, the way I do what you want is not through Excel, but through Reflection itself.  Open your Reflection settings file and go to the Connection Setup and choose a Connection Macro, which runs whenever that settings file is opened.


----------



## jfarc (Apr 15, 2013)

Yeah, it's really nice.  Your Reflection Macro can auto-logon to it's server, run it's routines, then auto-logoff and close the Refl window all without user intervention.  Some of this based on some other setups in the 'Connection Setup' menu in Refl.  Gotta check it out.


----------



## NitinShevkari (Apr 16, 2013)

Hey thanks for the help really appreciate  u really made my life easy
I got one probs. if u can help  actully before few months i have tried to save macro in r2w for auto login and i did mistake and all people from my team whenever they were opening this r2w file from their desktop they automatically started to get login with my credentials.... later i have deleted my macro. but now since few  months whenever my team is opening that r2w file from their own desktop... it is showing error " No "Login Macro found" (Login was the name of my macro) could you help me to remove this error? and if possible can you also tell me the script to close r2w file automatically? 





jfarc said:


> Yeah, it's really nice.  Your Reflection Macro can auto-logon to it's server, run it's routines, then auto-logoff and close the Refl window all without user intervention.  Some of this based on some other setups in the 'Connection Setup' menu in Refl.  Gotta check it out.


----------



## NitinShevkari (Apr 18, 2013)

Hi Guys, I know how to call WRQ Reflection  and its test.r2w file from excel macro but i don't know how to close it automatically via excel macro or any kind of vb scripting... can you please help!


----------



## jfarc (Apr 18, 2013)

This may rely on what version of WRQ Reflection you are running, but just go into the Reflection Menu item 'Connection Setup', 'More Setting' and click on the 'Exit on Disconnect' option.  Make sure to Save the Reflection settings file.

With this option turned on, then by either the User or your Reflection Macro simply logging off the server, then the Reflection window will close itself.


----------



## Robertson1995 (Apr 22, 2009)

I have the following code that I use in WRQ Reflections. It is very basic and runs the command bts_status mc800bts877. The characters "877" which are in red below is a site # which changes. What I need is for the macro to run the command bts_status mc800bts and then have an inputbox ask for the next 3 characters (in this example 877) that then carriage return after ok is selected on the input box. Thanks.


Sub Macro1()
' Generated by the Reflection Macro Recorder on 04-22-2009 09:01:25.57.
' Generated by Reflection for UNIX and Digital 8.0.6.
    On Error GoTo ErrorHandler
    Const NEVER_TIME_OUT = 0
    Dim CR As String    ' Chr$(rcCR) = Chr$(13) = Control-M
    Dim ESC As String   ' Chr$(rcESC) = Chr$(27) = Control-[
    CR = Chr$(rcCR)
    ESC = Chr$(rcESC)
    With Session
        .Transmit "bts_status mc800bts877" & CR
        ' .WaitForString ESC & "[K", NEVER_TIME_OUT, rcAllowKeystrokes
    Exit Sub
ErrorHandler:
    .MsgBox Err.Description, vbExclamation + vbOKOnly
    End With
    ' Recording stopped at 09:04:44.83.
End Sub


----------



## jfarc (Apr 18, 2013)

NitinShevkari said:


> it is showing error " No "Login Macro found" (Login was the name of my macro) could you help me to remove this error?



You still have the 'Connection Setup' / 'Connect Macro' entry set to your now deleted Login macro.  Just erase this setting and no more error.


----------

