Excel to AS/400 VBA – SETTEXT not working

85 pts.
Tags:
AS/400
iSeries AS/400
Hello, I am using Excel VBA to try to process a simply gettext/settext function. I am able to return a value using gettext, but nothing happens using settext...no error..nothing. I've pasted the code below. Any help is appreciated. Sub AS400_Test2() [PCOMM SCRIPT HEADER] Language = VBSCRIPT [PCOMM SCRIPT SOURCE] ' Initiate access to system Dim SessObj As Object Set SessObj = CreateObject("PCOMM.autECLSession") ' Initialize the session SessObj.SetConnectionByName ("A") Dim pcommPS, pcommOIA ' Get Handle to Current Emulator Session 'autECLSession.SetConnectionByName (ThisSessionName) ' Set Reference to Presentation Space area Set pcommPS = SessObj.autECLPS Set pcommOIA = SessObj.autECLOIA ' Find first data row of spreadsheet Dim FirstRow As Integer 'Variable for first data row Cells.Find(What:="ID", After:=ActiveCell, LookIn:=xlFormulas, _ LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _ MatchCase:=False, SearchFormat:=False).Activate FirstRow = ActiveCell.Offset(1, 0).row Dim LastRow As Long 'Variable for last data row Dim i As Integer 'Variable for loop counter Dim intMax As Integer 'Variable for maximum value of loop Dim strSignOn As String Dim strPass As String LastRow = Cells.Find("*", SearchOrder:=xlByRows, SearchDirection:=xlPrevious).row intMax = LastRow For i = FirstRow To LastRow strSignOn = Range("A" & i).Value strPass = Range("B" & i).Value strScrape = pcommPS.GetText(5, 23, 2) 'YAY!!! This works 'pcommPS.SetCursorPos 6, 23 pcommOIA.WaitForInputReady pcommPS.SetText "022", 6, 23 'pcommOIA.WaitForInputReady 'pcommPS.SendKeys "021", 24, 17 'pcommOIA.WaitForInputReady 'pcommPS.putstring strPass, 6, 23 'pcommOIA.WaitForInputReady 'pcommPS.SendKeys "[enter]" Next i Set pcommPS = Nothing Set pcommOIA = Nothing End Sub

Software/Hardware used:
Personal Communications iSeries Access for Windows-Workstation Program v6 for Windows
ASKED: April 30, 2013  11:13 AM

Answer Wiki

Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Discuss This Question: 6  Replies

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
  • TomLiotta
    Can you describe what the script is supposed to do? I don't use Excel, so I can't attach it to anything useful. -- Tom
    125,585 pointsBadges:
    report
  • TomLiotta
    BTW, I don't see that you have specified which field in the autECLFieldList item should receive the SetText() string. -- Tom
    125,585 pointsBadges:
    report
  • Carissa
    Tom, The code above is simply trying to put "022" in screen field 6,23. Once I can figure out how to get that working, I can make the macro do what it is supposed to do. I've tried settext, putstring, sendkeys..nothing works. I am not getting thrown any errors either, it just works through the code but nothing is sent to the screen.
    85 pointsBadges:
    report
  • TomLiotta
    Try making this change:
    'pcommPS.SetText "022", 6, 23
    pcommPS.autECLFieldList(1).SetText("022")
    I  don't know what's in the field list, so element (1) is mostly just a placeholder there. You might review the field elements from the presentation space to see how that screen gets decomposed into elements.
    .
    Where are you finding your documentation of the prototype for the SetText() method? I've seen examples on the web of people using the syntax that you used, but I haven't seen it documented that way.
    .
    Tom
    125,585 pointsBadges:
    report
  • Carissa
    Tom, Thank you. I tried your suggestion and am getting an index out of bounds error. I'm confused as to why the autECLFieldList would be a better option if I am already calling out the field (which doesn't work anyway ... ). I've been finding all bits of code on the web. I do not have documentation to go by.
    85 pointsBadges:
    report
  • TomLiotta
    AFAIK, the primary documentation on the web should be Host Access Class Library Automation Objects. It's not user-friendly by any stretch of the imagination. Much of it is on a single very long page that often has to be searched with a browser search function (i.e., {Ctrl-F}), and multiple variations of the product are all in different parts of that same page.
    .
    But reading down at least through the discussion of Figure 3 can provide some background.
    .
    Do you have a basic Support contract with IBM?
    .
    Tom
    125,585 pointsBadges:
    report

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following