Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Invalid Procedure Call or Argument

Status
Not open for further replies.

Tommeck37

Vendor
Jan 2, 2015
83
PL
Hello Dear Experts,

I am trying to get connection to Attachmate Extra (mainframe) in order to send some key strokes.
However, there seems to be missing some detail in a setup as I get Run-Time Error 5 saying "Invalid Procedure Call or Argument"


Does have anyone any idea what is missing in the below macro so that the connection can be made?

In addition to the procedure, I have References ticked out:

- Microsoft Visual Basic for Applications
- Microsoft Excel 14.0 Object Library
- Ole Automation
- Microsoft Office 14.0 Object Library

Here is the code I am using
Sub test() Dim System As Object
Dim Session As Object
Dim Screen As Object

On Error GoTo Err_h:

Set System = CreateObject("Extra.System")
If System Is Nothing Then Err.Raise 99999, "test sub", "Could not create Extra system object."

Set Session = System.ActiveSession
If Session Is Nothing Then Err.Raise 99999, "test sub", "Extra has not been launched. Please start the application."

Set Screen = Session.Screen
With Screen
.Putstring "CRO", 1, 4
.WaitHostQuiet (milliseconds)
.SendKeys ("")
End With

Clean_Exit:
Set Screen = Nothing
Set Session = Nothing
Set System = Nothing
Exit Sub
Err_h:
If Err.Number <> 0 Then
MsgBox "Error " & Err.Number & Chr(10) & Err.Description & Chr(10), vbCritical, "Error"
End If
GoTo Clean_Exit
End Sub


Thank you for any directions in solving the problem

Regards

Tommeck37
 
when this loops runs out of screens, the session automatically goes out of session to the first screen where you input nostro number (account number etc, "it goes back to door of account")

 
So what you are telling me is that there your system has no MESSAGE AREA that tells you there's MORE, or that you're DONE or that you encountered some ERROR CONDITION?

What you're saying is that you program has to SOMEHOW determine when it "sees" the original screen again? Well YOU have to tell me how that recognition will occur, or somehow logically describe that condition, that can then be translated into VB code. I can't tell you how your screen/system operates. It is TOTALLY foreign to the experiences I've seen in 30 years in the aerospace industry in 4 different companies.
 
So this is how it goes

1. Vba enters Session CRO from list of sessions
2. On the screen of CRO it enters account number (nostro number) and the reference (in the line below)
3. then opens a screen where the loop does its job. It goes and goes until screens run out and it kicks it out back to point 2 where you normally enter account number and reference below the line.

I would guess that the loop could have a condition that if it sees the initial screen of the CRO it should stop

Yes, there is some piece of info at the bottom of screen when the session is kicked out to initial screen of CRO when the Loop still tries to enter values that was entering inside of session CRO.
The screen shows some sort of info like wrong data or something like that. Generally, initial screen is open of CRO and vba still tries to putstring values on 5, 54 lines while there is no space for such input.

Kind Regards
Tommeck37
 
Please do not talk to me about what your VBA is doing at this point.

I need to know how this system operates, and yes, it is VERY important about the "some piece of info at the bottom of screen" that seems to you as some insignificant throw away, hardly worth mentioning, just in passing, when I've asked more than once for this kind of information. SOP for loops!

So would you care to let the cat out of the bag: what's going on with the message area?
 
Hi,

I will get you every detail of that information but only tomorrow as I have left the office for today.


Kind Regards
Tommeck37
 
Hello,

So I am back with the information

System shows precisely this message: *** CRO 001 : WRONG OPERATION ***

whereas CRO 001 is the name of the session

below that line, there is a small clock colon and number: "00.1" at the end of line localization of cursor 11/27


That's what is visible when the macro still tries to loop

Kind Regards
Tommeck37
 
But surely ther is more than that single message.

What about when you need to hit the ENTER key to get another screen?

And what about when you need not hit ENTER to get another screen?

Are thee no messages in those circumstances?
 
your code should stop when the cursor is at 11/27
or when it sees the first screen. surely, there's something on the first screen that is unique. for example, maybe the first screen says "ENTER HERE" at position 2,2. Then all you need to do is to look for that narrative
 
Hello

I finally reached the expected result.
What I did was to give a condition for a loop to check content of screen when all job is done by a loop and session is kicked out to initial screen.

this is the code that works peferctly

Code:
Sub Main()
Num = Application.InputBox("Enter nostro Number")
Num1 = Application.InputBox("Enter what to change into")
Num2 = Application.InputBox("Enter what to change")


        Dim Sys As Object, Sess As Object, Screen As Object
    Set Sys = CreateObject("EXTRA.System")


' Assumes an open session
    Set Sess = Sys.ActiveSession
        Set Screen = Sess.Screen
        

        
With Screen
        .PutString "CRO", 1, 4
       .SendKeys ("<enter>")
       .WaitHostQuiet (100)
       .PutString Num, 11, 27
       .MoveTo 13, 27
       .PutString Num2, 13, 27
       .SendKeys ("<enter>")
       .WaitHostQuiet (200)
    End With
    

    Do Until Sess.Screen.GetString(11, 3, 6) = "NOSTRO"
With Screen

       .PutString Num1, 5, 54
       .SendKeys ("<enter>")
       .WaitHostQuiet (100)
       .PutString "y", 16, 27
       .SendKeys ("<enter>")
       .WaitHostQuiet (100)
   
End With
 Loop
 
 MsgBox ("Reference has been changed")
   
Clean_Exit:
    Set Screen = Nothing
    Set Session = Nothing
    Set System = Nothing
    Exit Sub
Err_h:
 If Err.Number <> 0 Then
    MsgBox "Error " & Err.Number & Chr(10) & Err.Description & Chr(10), vbCritical, "Error"
 End If
 GoTo Clean_Exit
End Sub

The only missing thing in this application is an outcome for "Cancel" button in InputBox

Is there a way to just let the application finish executing code and showing a simmple message like "Nothing was done"??

Kind Regards
Tommeck37
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top