Alex037

Reading row cells sequentially?

12 posts in this topic

Hello everyone,

I have been searching through General Help and Support subforum trying to figure out the possible solution. I have been introduced to AutoIT years ago, and did performed some relatively basic tasks. Now, I'd like to automate one process that will eventually fall on someone else, but if it can be done, it's worth it.

I have 3 computers on a separate location, without internet access. They will be filling two excel files on a daily basis. I'm guessing there will be 5-8 columns (depending on the information entered), and maybe 50-100 rows per operater.  Due to the fact that the computers are without internet access, workers will have to go every day to central location and feed the info into database via browser (after work). Basically, it is a list of names, social ID's, doctors, prescriptions, etc. Now, it would be great to just import the data into MySql, but I am not allowed to do that (and I don't have access to it).  "Simplest" solution so far is pointing me to AutoIT. Combine daily excel files into a single one, and let the machine enters the data via browser. For example, read 1st row (cell by cell), and then paste the content in a web form. Once completed, go to 2nd row, and so on. One more problem is that I have different number of columns per row (in this case, per patient).

I see that the Excel UDF is playing a big part of it, and I have a hunch that is pointing me to arrays, but I'm not quite sure how to handle it. Furthermore, there are few radio buttons on a form that has to be delt with (but those are always the same, so this should not be a problem).

I'd appreciate any help / hint.

Thanks.

 

Share this post


Link to post
Share on other sites



Welcome to AutoIt and the forum!

Correct, the Excel UDF and some array processing should do what you need.
Function _Excel_rangeRead allows to read single cells, rows or columns as a whole and even all used cell in a worksheet.

Based on the kind of data you handle security is an issue? Means if something goes wrong you would need to be able to restart where the processes was interrupted. There should be a log of all activity etc.

Depending on this requirements a different sign should be used. But it shouldn't be too hard ;)

 


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Many thanks for your welcome and fast reply.

Idea is that one of the operator monitors the process of data entry. There are three operators, spending additional half hour every few days is still much better than spending few additional hours daily. This way, it should be done a lot quicker (and if something goes wrong, he/she will be able to respond). This problem will be dealt with or by gaining internet access, or a local copy of a database, but both solutions will take approximately 2-3 months. If it can be done with AutoIT, I'm willing to try to resolve it (and to gain additional knowledge, of course).

I will look into Excel UDF tonight, and I'll see how it goes. I will get back to sometime tomorrow :-)

Thank you for your time and help.

Share this post


Link to post
Share on other sites

Will post an example on monday when i return to my WIndows PC.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

That would be great. I spent some time learning and playing with Excel UDF, and so far I can perform some basic tasks. I have looked all examples, and it would be neat if there is a possibility to extract the content of a single cell (once the row, or entire sheet has been copied), and then paste that content. Or, copy row, paste cell content sequentially... 

Share this post


Link to post
Share on other sites

Here is a first try:

#include <Excel.au3>

Global $oExcel = _Excel_Open(True) ; Set this to False to let Excel run in the background
Global $oWorkbook, $aUsedRange

_ProcessWorkbook("C:\temp\test1.xlsx") ; Process workbooks 1 to 3
_ProcessWorkbook("C:\temp\test2.xlsx")
_ProcessWorkbook("C:\temp\test3.xlsx")

Func _ProcessWorkbook($sWorkbook)

    $oWorkbook = _Excel_BookOpen($oExcel, $sWorkbook) ; Open the Workbook
    $aUsedRange = _Excel_RangeRead($oWorkBook) ; Read all used cells
    For $i = 0 To UBound($aUsedRange, 1) - 1 ; Process all rows of the Workbook
        For $j = 0 To UBound($aUsedRange, 2) - 1
            ; Should the input be checked for valid data (empty cells ...)?
            ; Send the content to the browser here
        Next
    Next
    _Excel_BookClose($oWorkbook, False)

EndFunc

Which Browser do you want to use?

1 person likes this

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Thank you very much for answering,

Target machine is a default Windows 10 OS, with almost nothing on it. IE browser is used. Each row should be checked for first empty cell, only as a signal to move to another row (if it will work that way). I'm guessing that each row will have 5-8 columns (no more), so 1st empty cell in each row will indicate the end of that row. That may serve as a signal to the rest of the AutoIt script to complete entry, and start again.

Share this post


Link to post
Share on other sites

Next step is to identify the fields in IE where the data should be sent to. You can access them by Name (function _IEFormElementGetObjByName) or by ID (function _IEGetObjById).
The example in _IEFormElementGetObjByName shows how to write data to a field in a browser form.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Thank you. I will be playing with it and let you know about it tomorrow. Looks like I have a lot of learning to do.

Share this post


Link to post
Share on other sites

Correct ;)


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

I have managed to identify the fields, and I am still playing with it. Actually, I am still struggling with it. I'd give it a few more days to spend on it (in my free time), and will let you know about any progress. I cannot figure ubound. How to paste one cell value at a time, or how to paste them in appropriate boxes.

Share this post


Link to post
Share on other sites
UBound($aUsedRange, 1)

Simply returns the size of a dimension of an array. Parameter 2 defines the dimension to check: 1: Returns the number of rows, 2: Returns the number of columns


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now