×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Invalid Procedure Call or Argument

Invalid Procedure Call or Argument

Invalid Procedure Call or Argument

(OP)
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

RE: Invalid Procedure Call or Argument

Hi,

You never stated the statement that the error occurred pn!

I'd guess

Set System = CreateObject("Extra.Application")


RE: Invalid Procedure Call or Argument

(OP)
Hello,

Thank you for very quick answer

Correct me if I am wrong.

I should replace "System" with "Application" for all statements?

Kind Regards
Tommeck37

RE: Invalid Procedure Call or Argument

No! You're creating an application object that you have named System.

RE: Invalid Procedure Call or Argument

(OP)
Hi,

In that case, I will change the code to:

Sub test()
Dim System As Object
Dim Session As Object
Dim Screen As Object

On Error GoTo Err_h:

Set System = CreateObject("Extra.Application")
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 (1000)
.SendKeys ("<enter>")
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

Will that be ok now?


PS. I will only be able to check the code with Attachmate on Monday once I get to the office.
Regards
Tommeck37

RE: Invalid Procedure Call or Argument

(OP)
Hey,

I changed:

Set System = CreateObject("Extra.System")
to
Set System = CreateObject("Extra.Application")

And there is an error 429 ActiveX component can't create object.

I think this is because "Application" does not belong to Attachmate's object model. As far as I am aware this is "system" that is, in the highest position to which binding should be made.

Kind Regards
Tommeck37

RE: Invalid Procedure Call or Argument

This is how my code looks

CODE

Sub test()
    Dim Sessions As Object
    Dim System As Object
    Set System = CreateObject("EXTRA.System")
    Set Sessions = System.Sessions
    Set sess = System.activeSession
    Set screen = sess.screen

    With screen
        .putstring "CRO", 1, 14
        .WaitHostQuiet (50)
    End With
    
End Sub 

RE: Invalid Procedure Call or Argument

(OP)
Another attempt fails

Now the error is

Run-Time Error '91'
Object Variable or With block Variable not set

Kind Regards
Tommeck37

RE: Invalid Procedure Call or Argument

(OP)
I've tried many codes which other people use successfully but not here.

Perhaps I should tick out something in Attachmate?

Kind Regards
Tommeck37

RE: Invalid Procedure Call or Argument

can you post you latest code

RE: Invalid Procedure Call or Argument

(OP)
Hello,

This is the code

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 (1000)
.SendKeys ("<enter>")
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

The error that generates here is : "Invalid Procedure Call or Argument"

Of course I've tried your above code with error as stated above.

Kind Regards
Tommeck37

RE: Invalid Procedure Call or Argument

Tommeck37,
I wanted to see if I can duplicate your error.
just curious, do you have an active Attachmate session open? I get an "Error 5 Invalid procedure call or argument" when there is no session available.

btw, what version of Excel and Attachmate are you using?
your code does work on my Excel 2010/Attachmate Extreme 9.3. I did not do anything special with any settings in Attachmate nor Excel.

rem

RE: Invalid Procedure Call or Argument

(OP)
Hi,

It seems to me the problem lies in applications' settings.

I am using excel 2010. Attachmate is open and active. I tried with only one session. I've tried with multiple sessions. I am using two monitors.
I tried one both monitors and I tried on one monitor excel and attachmate.

Maybe there is something with the file of attachmate I am starting application with.
Attachmate and excel are run via Citrix. Maybe here is something to do with the problem.

At least I am sure that the code is correct. This is some step forward with the problem.

Kind Regards
Tommeck37

RE: Invalid Procedure Call or Argument

An unrelated comment on your code:

The PutString() function communicates directly with the screen and requires no delay in your code.

However, SendKeys() does, since this communication is with the mainframe and is asynchronous which means that the mainframe's response could be 1 second, 1 minute, 1 hour; no one knows! So simply to wait a predetermined period of time is akin to deciding that you'll wait 15 seconds at each traffic light or stop sign before proceeding through an intersection! A better method is to use something like WaitForCursor after SendKeys, in a loop.

RE: Invalid Procedure Call or Argument

(OP)
Hello,

Maybe the problem is with making the session active?

How do I make a session active? If I activate excel (macro initiator), is Attachmate active then?

Maybe the problem is that simple?

Kind Regards
Tommeck37

RE: Invalid Procedure Call or Argument

The active session is the one that you defined in your code. It is active even when your Excel is active and your code is running.

RE: Invalid Procedure Call or Argument

(OP)
Hello,

I got a code that is supposed to bind Attachmate successfully in my office. (I do not know what was the matter with the previous one, version maybe)
However, I received it in notepad. I do not know how to execute it. Can this code be somehow input to Excel VBE so that it can be run as a regular Sub End sub procedure?

I have attached the file with the code

Thank you
Tommeck37

RE: Invalid Procedure Call or Argument

Copy the text and paste into a new module in Excel VB editor.

RE: Invalid Procedure Call or Argument

(OP)
That's what I've tried to do.

However, how to execute the code then if this is Private Sub?
I have no idea about userforms and events etc.

Do I have to create a sort of button that would trigger a specific code?

Thank you
Tommeck37

RE: Invalid Procedure Call or Argument

Sure, whatever it takes to kick off the correct sub.

RE: Invalid Procedure Call or Argument

(OP)
Hello,

Could anyone try if the below code works for you?
I think I am facing not-VBA-type problem with connection.

CODE --> VBA

'   MACRO NAME:    excel.ebm
'   DATE WRITTEN:  11/21/97, Attachmate Automation Support (ng)
'   DESCRIPTION:   For use with EXTRA! Personal Client 6.x (and derivatives).
'                  Also requires 32-bit Microsoft Excel to be installed.
'
'   NOTES:         This macro illustrates how an Excel spreadsheet can be accessed
'                  and manipulated from within an EXTRA! Basic macro. The macro does
'                  the following steps:
'                  1. Connect to the currently active EXTRA! session.
'                  2. Start Excel.
'                  3. Create an new .xls file (workbook) and save it.
'                  4. Copy the current screen in EXTRA! to the Excel worksheet.
'                  5. Save the worksheet.
'
'                  EXTRA! Basic and Excel VBA are extremely similar. Note that this
'                  macro will run perfectly if the body of it is copied to a Sub in
'                  an Excel module.
'
'
'                  ˆ Copyright 1989-1997, Attachmate Corporation. All Rights Reserved.
'
'                  This macro is provided as an example only. It is provided as-is,
'                  without warranty or support from Attachmate Corporation.
'
'==============================================================================

Sub Main()
    
    Dim sys As Object, sess As Object, xl As Object, wb As Object
    Dim iCount As Integer, iRows As Long, iCols As Long
    Dim sFile As String
    
    sFile = "C:\EXTRAScreenCopy.xls"
    
    
    'GET ACCESS TO THE TOP LEVEL E!PC OBJECT...
    Set sys = CreateObject("Extra.System")
    If sys Is Nothing Then
        MsgBox ("Could not create Extra.System...is E!PC installed on this machine?")
        Exit Sub
    End If
    
    'GET ACCESS TO THE CURRENTLY ACTIVE SESSION...
    Set sess = sys.ActiveSession
    If sess Is Nothing Then
        MsgBox ("No session available...stopping macro playback.")
        Exit Sub
    End If
        
    'START EXCEL...IT WILL NOT BE VISIBLE YET, BUT WILL STILL BE IN MEMORY....
    'THIS IS THE SAME AS STARTING EXCEL WITH NO CURRENT WORKBOOK
    Set xl = CreateObject("Excel.Application")
    If xl Is Nothing Then
        MsgBox ("Could not create Excel.Application...is Excel installed on this machine?")
        Exit Sub
    End If
        
    
    'CREATE A NEW WORKBOOK...THIS IS JUST LIKE CHOOSING 'FILE-NEW...'
    Set wb = xl.Workbooks.Add
    If wb Is Nothing Then
        MsgBox ("Add method of Excel Workbooks object failed.")
        xl.Quit
        Exit Sub
    End If
        
    
    'SAVE THE NEW WORKBOOK JUST CREATED...
    'AN ERROR WILL OCCUR IF THIS FILE CURRENTLY EXISTS AND THE USER CHOOSES
    'NOT TO REPLACE THE EXISTING OR CHOOSES CANCEL...
    'AN ERROR WILL ALSO OCCUR IF THE SPECIFIED .XLS IS CURRENTLY OPEN,
    'SO CLOSE IT BEFORE RUNNING THIS MACRO....
    On Error GoTo error_exit
    wb.SaveAs (sFile)
        
    iRows = sess.Screen.Rows
    iCols = sess.Screen.Cols
        
    'COPY THE CURRENT SCREEN TO THE WORKSHEET...
    'IT'S LIKELY TO LOOK BEST IF A NON-PORPORTIONAL FONT IS USED.
    For iCount = 1 To iRows
        wb.Worksheets("sheet1").Cells(iCount, 1).Value = sess.Screen.GetString(iCount, 1, iCols)
        wb.Worksheets("sheet1").Cells(iCount, 1).Font.Name = "Courier New"
    Next iCount
        
    'SAVE THE CHANGES TO THE WORKBOOK THEN QUIT EXCEL...
    wb.Save

error_exit:
    
    xl.Quit
    If Err Then
        MsgBox sFile + " was not replaced."
    Else
        MsgBox "Created  " + sFile
    End If
    
    Exit Sub
                            
End Sub 


Thank you
Tommeck37

RE: Invalid Procedure Call or Argument

So what statement is the problem?

RE: Invalid Procedure Call or Argument

(OP)
Hello,

It seems that it is not the code that causes problem.
I've tried many codes which work successfully on other machines but not on mine. Therefore I must conclude that there is missing some sort of setup in attachmate that makes it unavailable for excel to obtain connection through CREATEOBJECT function.

I posted the above code to double confirm if another code works fine on another machine rather than mine, which gets me to the above conclusion.

Do you know perhaps if there is anything I should check with Attachmate (Options, preferences etc) that could be not switched on to be able to bind connections with excel VBA?


Kind Regards,
Tommeck37

RE: Invalid Procedure Call or Argument

Tommeck37,
did you check Citrix?

RE: Invalid Procedure Call or Argument

(OP)
Hello,

I finally moved with the problem forward. It turned out that this version of system accepts different object names.
I copied sample codes from producer's website and binding was ok.

Now I cannot move on with the code

CODE --> vba

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
       .WaitHostQuiet (100)
       .SendKeys ("<enter>")
       .PutString "8038813", 11, 27
       .MoveTo 13, 27
       .PutString Num2, 13, 27
       .SendKeys ("<enter>")
           
    End With
    

    
With Screen
        Screen.MoveTo 5, 54
        .PutString Num1, 5, 54
       .WaitHostQuiet (100)
       .SendKeys ("<enter>")
       .PutString "y", 16, 27
       .SendKeys ("<enter>")
    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 

The application should go into session "CRO" then enter what I input in InputBox (account number) then two line below another input from InputBox and press enter and repeat that with a loop.

Oddly, the application only goes into CRO and stops.

Would you have any idea how to make it move all the way into account given in InputBox.

Kind Regards
Tommeck37

RE: Invalid Procedure Call or Argument

I see no loop.

Furthermore you're entering CRO, waiting 100 ms for what, (nothing has happened yet, you just put some characters on the screen), THEN you SendKeys ASYNCHRONOUSLY to the mainframe with no idea when the mainframe will respond. HERE is where you need to wait UNTIL THE MAINFRAME RESPONDS WITH THE CRO STUFF, before you Put anothing on the screen!

RE: Invalid Procedure Call or Argument

(OP)
Yeah, it works. The app went in and did the job.

What kind of loop should be ok? The thing is to loop until the app will be able to enter specific account entry while pressing "enter". Items end when after enter key there is no entry on the screen visible.

Do Loop? But how to apply to the entire "With" block?


Kind Regards
Tommeck37

RE: Invalid Procedure Call or Argument

Where is the data for entry in a loop?

RE: Invalid Procedure Call or Argument

(OP)
Here is the block I would like to loop until machine will be able to go, until attachmate will stop it

CODE --> vba

With Screen
        Screen.MoveTo 5, 54
        .PutString Num1, 5, 54
       .WaitHostQuiet (100)
       .SendKeys ("<enter>")
       .PutString "y", 16, 27
       .SendKeys ("<enter>")
       .WaitHostQuiet (100)
    End With 

RE: Invalid Procedure Call or Argument

Well that's not really the makings of a loop. A loop is when you repeat the same things with different data. In this example you are merely doing two things one time.

Now if you had a source, lets say your Input Box...

CODE

'
   With Screen
     Do
        Num = Application.InputBox("Enter nostro Number")
        If Num = "" Then Exit Do
        Num1 = Application.InputBox("Enter what to change into")
        Num2 = Application.InputBox("Enter what to change")
     
        .PutString Num1, 5, 54
        .SendKeys ("<enter>")
        Do Until .waitforcursor(r, c)
            DoEvents
        Loop
        
        .PutString "y", 16, 27
        .SendKeys ("<enter>")
        Do Until .waitforcursor(r, c)
            DoEvents
        Loop
        
      Loop
    End With 
...but I have no idea what Num and Num2 are being used for???

RE: Invalid Procedure Call or Argument

...but then the user has to be sitting there entering data and waiting for the mainframe to respond, which may be okay in some circumstances.

In my experience, that data has either been entered into a spreadsheet or imported, and that list is used to populate the screen in a loop.

RE: Invalid Procedure Call or Argument

(OP)
No, No.

The above loop repeats the first block which is not needed

I will try to explain more in details

This part:

CODE --> vba

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 

enters session "CRO", then opens account number (given in Input Num) goes line below to enter reference number (Num2) and presses enter to go into account view. Then code

CODE --> vba

With Screen
       
        .PutString Num1, 5, 54
       .SendKeys ("<enter>")
       .WaitHostQuiet (100)
       .PutString "y", 16, 27
       .SendKeys ("<enter>")
       .WaitHostQuiet (100)
    End With 

Replaces reference in line 5, 54 with what I input in InputBox (Num1), confirms by pressing "enter" confirm with writing letter "Y" in line 16, 27 and then it should go up again to line 5, 54 replace reference with Num1, "enter" and confirm by writing y in line 16, 27 and so on and so on until it will not be possible to do it because system will stop it. I would then trigger some sort of MsgBox like "changing reference is finished"

All in all, the loop is needed for the entire second bloc which changes reference presses enter and writes "Y" and presses enter to go on to next reference which will be changed again.

Cheers
Tommeck37

RE: Invalid Procedure Call or Argument

I did NOTHING with your first block containing CRO!!! I don't understand how your screen works, ie what is being entered and what system responses etc.

What do you mean by "confirms by pressing 'enter'?"

What is the confirmation that the system returns?

RE: Invalid Procedure Call or Argument

(OP)

I did not express myself correctly

By pressing enter I meant sending key to the screen

it goes like this

puts string from Num1 to line 5, 54, sends enter then sends keys "Y" to the screen and then sends "enter" again - this process I would like to repeat as long as system will allow.

System response to my last "enter in this loop' is that it goes on to next screen with next reference (which I'd like to change into different one, and then anothe screen and another etc)

All in all, this is going from screen to next screen and replacing existing reference with reference given in InputBox

RE: Invalid Procedure Call or Argument

You PUT text on the screen without any SendKeys, cuz SendKeys does not PUT anything ON the screen. SendKeys talks to the system with whatever is sent, sends the system off ASYNCHRONOUSLY to do whatever you told it to do and then returns some response after ??? Period of time.

So do you PUT "Y" on the screen or do you SendKeys "Y" then wait for a response and then SendKey ENTER and wait for a response?

Then you go to the next screen with a reference "I'd like to change". Well how do you want to change the reference without an InputBox IN THE LOOP?

Every system I've worked with over the past 30 years, has a specific area on the screen for the system to tell you what's happeneing. Simple getting another screen ODBC data is not enough. SOMEWHERE it must say something like MORE and DONE!

RE: Invalid Procedure Call or Argument

(OP)
I put "Y" on the screen then SendKey "Enter" and after this system goes on to next screen
Then I would like to go back to line 5, 54 and do the same that is put string of numbers which come from InputBox, sendkey "enter" put "Y" on the screen and go on to next screen by SendingKey "Enter"

The code I have so far is good as it does the job well but only once. All is needed is to make it repeat that phase on and on


RE: Invalid Procedure Call or Argument

Did you consider the code I posted?

RE: Invalid Procedure Call or Argument

(OP)
Of course :)

It asked me for Num Num1 and Num2 multiple times


What do you think of this

CODE --> vba

Do While Session.GetString, 5, 54 = ""
With Screen
       
        .PutString Num1, 5, 54
       .SendKeys ("<enter>")
       .WaitHostQuiet (100)
       .PutString "y", 16, 27
       .SendKeys ("<enter>")
       .WaitHostQuiet (100)
    End With 
Loop 

I cannot check it now as I am out of office

RE: Invalid Procedure Call or Argument

Again, What do you think this does not do that you just asked for?

CODE

'
   With Screen
     Do
        Num = Application.InputBox("Enter nostro Number")
        If Num = "" Then Exit Do
        Num1 = Application.InputBox("Enter what to change into")
        Num2 = Application.InputBox("Enter what to change")
     
        .PutString Num1, 5, 54
        .SendKeys ("<enter>")
        Do Until .waitforcursor(r, c)
            DoEvents
        Loop
        
        .PutString "y", 16, 27
        .SendKeys ("<enter>")
        Do Until .waitforcursor(r, c)
            DoEvents
        Loop
        
      Loop
    End With f 

RE: Invalid Procedure Call or Argument

(OP)
Hello

I tried the above but this asks many times to enter Num, Num1 and Num2 which multiplies the workload

I managed to figure out a loop like the below but this is not enough. Missing is the condition to stop looping because this code loops endlessly and therefore I have to kill (by task manager) excel in order to stop it :)

What condition can I put to loop in order to stop it? I've tried with

CODE --> vba

Do until sess.screen.getstring (5, 54 , 8) = "" 
but it does not work

This is the code that loops endlessly

CODE --> vba

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  
With Screen
       
        .PutString Num1, 5, 54
       .SendKeys ("<enter>")
       .WaitHostQuiet (100)
       .PutString "y", 16, 27
       .SendKeys ("<enter>")
       .WaitHostQuiet (100)
    End With
Loop
   
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 

Kind Regards
Tommeck37

RE: Invalid Procedure Call or Argument

What tells you that tis the last screen? How do you know?

RE: Invalid Procedure Call or Argument

(OP)
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")

RE: Invalid Procedure Call or Argument

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.

RE: Invalid Procedure Call or Argument

(OP)
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

RE: Invalid Procedure Call or Argument

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?

RE: Invalid Procedure Call or Argument

(OP)
Hi,

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


Kind Regards
Tommeck37

RE: Invalid Procedure Call or Argument

(OP)
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

RE: Invalid Procedure Call or Argument

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?

RE: Invalid Procedure Call or Argument

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

RE: Invalid Procedure Call or Argument

(OP)
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 --> VBA

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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close