Solved

Automatic Data Entry to AS400 Screen from Excel File

Posted on 2008-06-13
3
1,630 Views
Last Modified: 2008-06-13
I am working on a script to automate data entry to AS400 screen from Excel data. My script is below. I have found a simple script to enter "selected" cell data, but am trying to enter multiple rows of records. I need assistance in setting the range to a block of cells and then reading that data.

I have placed astericks around the area requiring modification.

[PCOMM SCRIPT HEADER]
LANGUAGE=VBSCRIPT
DESCRIPTION=
[PCOMM SCRIPT SOURCE]
OPTION EXPLICIT
autECLSession.SetConnectionByName(ThisSessionName)

GetExcelData

sub GetExcelData()
Dim oXL, oRange, oCell
Dim curVal, i

Set oXL = GetObject(,"Excel.Application")
If oXL Is Nothing Then
MsgBox "You need to have the Excel list open!"
Exit Sub
Else

REM ***********************************************************
Set oRange = oXL.Application.Selection
REM ***********************************************************


End If
With autECLSession
For each oCell in oRange
curVal = oCell.Value
.autECLOIA.WaitForAppAvailable
.autECLOIA.WaitForInputReady
.autECLPS.SendKeys "[pf16]"
.autECLPS.SendKeys curVal, 5, 39
.autECLPS.SendKeys "[enter]"
.autECLOIA.WaitForInputReady
.autECLPS.SendKeys "1"
.autECLPS.SendKeys "[enter]"
.autECLPS.SendKeys "[pf10]"
Next
End With
End Sub

0
Comment
Question by:tom616wilson
  • 2
3 Comments
 
LVL 35

Expert Comment

by:mvidas
ID: 21778267
Hi Tom,

Why not just select the multiple cells you want to enter prior to running? If you want it fully automated, how do you determine which cells you want to have entered?

Also, from my experience it is usually worthwhile to put a waitforinputready after pressing enter or any F-key; the as400 machine I use can get laggy and my macro will skip a step.

Matt
0
 

Author Comment

by:tom616wilson
ID: 21778479
Matt,
That is what I'll do.

If I select a block of cells, say C(1,1) through C(5,5); in what order does the "For each oCell in oRange" statement step through the cells?

Thanks,
Tom



0
 
LVL 35

Accepted Solution

by:
mvidas earned 50 total points
ID: 21778550
By default, it goes by rows first, so it'll do A1, then B1, C1, D1, E1, A2, B2, etc

If you want it to go by columns, add oCol to your Dim statement and change your for/next loop to the attached snippet.

Matt
 For Each oCol In oRange.Columns

  For Each oCell In oCol

   curVal = oCell.Value

   .autECLOIA.WaitForAppAvailable

   .autECLOIA.WaitForInputReady

   .autECLPS.SendKeys "[pf16]"

   .autECLPS.SendKeys curVal, 5, 39

   .autECLPS.SendKeys "[enter]"

   .autECLOIA.WaitForInputReady

   .autECLPS.SendKeys "1"

   .autECLPS.SendKeys "[enter]"

   .autECLPS.SendKeys "[pf10]"

  Next

 Next

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Not long ago I saw a question in the VB Script forum that I thought would not take much time. You can read that question (Question ID  (http://www.experts-exchange.com/Programming/Languages/Visual_Basic/VB_Script/Q_28455246.html)28455246) Here (http…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now