# How to get table cell one by one?

Go to solution Solved by AlessandroAvolio,

## Recommended Posts

Hello.

I have IETable,

Get by this code

```\$oTable = _IETableGetCollection (\$oIE, 1)
\$aTableData = _IETableWriteToArray (\$oTable)

Local Const \$iArrayNumberOfCols = UBound(\$aTableData, \$UBOUND_COLUMNS)
Local Const \$iArrayNumberOfRows = UBound(\$aTableData, \$UBOUND_ROWS)
Local \$aArraySubstringsRow[\$iArrayNumberOfCols]

;~ Local \$aExtract = _ArrayExtract (\$aTableData, 1, 1, 1, -1)
;~ MsgBox(0, "", \$iArrayNumberOfCols)

;~ _ArrayDisplay(\$aExtract)
Local Const \$iArrayRowIndex = 1

Local \$sSubstring

For \$i = 0 To \$iArrayNumberOfCols - 1
\$sSubstring = StringLeft(\$aTableData[\$iArrayRowIndex][\$i], 2)
\$aArraySubstringsRow[\$i] = \$sSubstring
Next

_ArrayDisplay(\$aArraySubstringsRow, "This is a row")```

and i want to use cell (52, 82, 18, 9,...10) one by one for selecting dropdown box in internet explorer.

So, How to show/get/extract cell one by one (in msgbox)?

##### Share on other sites
• Solution

You need basic concept of "accessing data in array": https://www.autoitscript.com/wiki/Arrays#Accessing_Data_in_Arrays

```Local \$aArray[3] = [1, 2, 3]

For \$i = 0 to Ubound(\$aArray) -1
msgbox(0, "", \$aArray[\$i])
Next```

## Create an account

Register a new account

• ### Similar Content

• Hi, first of all thanks to all the guys who always help people in the forums, I wouldn't be able to do anything if wasn't for your help, even if I don't ask it myself.

I've created this code to get some info on a monitoring network on my work. It relays on _IETableGetCollection and _IETableWriteToArray.
It works well, but take around 3:25 minutes to get the info from 28 pages (some of them are large and take longer to load, but most of them are small and fast).
My question is if you see a way to get the program to go faster...

I've tried to make it easy for you to understand and edited somethings with sensitive info.
(Some of the pages doesn't have the black divider with MIRA in the end, so I need to search if it is there or not.)

#include <IE.au3> #include <array.au3> Local \$oIE = _IECreate("about:blank", 0, 0) Local \$paginas[28] = [89, 90, 91, 92, 93, 96, 105, 113, 119, 125, 126, 129, 131, 133, 135, 137, 139, 140, 141, 144, 145, 146, 148, 149, 150, 151, 158, 159] Local \$Datos_array[0][2] Local \$oTable Local \$tabla Local \$aux_x = 1 Local \$ar = 1 Local \$Numtables_datos = 0 MsgBox(0, "asd", "asd") For \$pag = 0 To UBound(\$paginas) - 1 Step 1 _IENavigate(\$oIE, "<WEBSITE URL>" & \$paginas[\$pag]) ; <<< the pages to load are always the same except for the last digits. _ArrayAdd(\$Datos_array, \$paginas[\$pag] & "|" & "Entrante", 0, "|") ; <<<<<<<<<<<<<<<< adds the page number toarray [0, 0] ;############################################ START counts amount of tables with traffic \$oTable = _IETableGetCollection(\$oIE) Local \$iNumTables = @extended For \$i = 3 To \$iNumTables - 2 Step 1 \$oTable = _IETableGetCollection(\$oIE, \$i) \$nomb_tabla2 = _IETableWriteToArray(\$oTable) ; <<<<<<<< TABLE TO ARRAY. \$string2 = StringStripWS(\$nomb_tabla2[1][0], 8) If \$string2 <> "MIRA" Then \$Numtables_datos = \$Numtables_datos + 1 Next \$tabla_End = \$iNumTables - \$Numtables_datos ;############################################ FIN \$tabla_Start = 4 \$tabla_trafico = 2 For \$for = 1 To \$Numtables_datos Step 1 \$oTable = _IETableGetCollection(\$oIE, \$tabla_Start - 1) ; <<<<<<<<<<< NAME OF THE TABLE; row2 = mira \$nomb_tabla = _IETableWriteToArray(\$oTable) ; <<<<<<<< TABLE TO ARRAY ;########################################### ADDS the traffic number into the row \$string = StringStripWS(\$nomb_tabla[1][0], 8) If \$string == "MIRA" Then ;si o si pasa por aca 1 vez _ArrayAdd(\$Datos_array, \$nomb_tabla[0][0]) \$nomb_aux = \$nomb_tabla[0][0] \$aux_x = 1 \$tabla_trafico = \$tabla_trafico + 2 Else ;esto deberia ser por row _ArrayAdd(\$Datos_array, \$nomb_aux & " " & \$aux_x) \$aux_x = \$aux_x + 1 \$tabla_trafico = \$tabla_trafico + 1 EndIf \$oTable = _IETableGetCollection(\$oIE, \$tabla_trafico) Local \$aTableData = _IETableWriteToArray(\$oTable) \$bps = _ArrayToString(\$aTableData, "|", 0, 0, @CRLF, 0, 0) \$bps = StringRight(\$bps, 5) \$bps = StringLeft(\$bps, 4) \$trafico_actual = _ArrayToString(\$aTableData, "|", 0, 0, @CRLF, 2, 2) If \$bps == "Gbps" Then \$trafico_actual = \$trafico_actual * 1000 If \$bps == "Kbps" Then \$trafico_actual = \$trafico_actual / 1000 \$Datos_array[\$ar][1] = \$trafico_actual \$ar = \$ar + 1 If \$string == "MIRA" Then \$tabla_Start = \$tabla_Start + 2 Else \$tabla_Start = \$tabla_Start + 1 EndIf Next \$ar = \$ar + 1 ;~ ############# CAÍDA ############ ;~ If \$actual_entrante = 0 Then ;~ \$xxx = 0 ;~ Do ;~ MsgBox(0, "Tráfico Caído", \$paginas[\$i], 5) ;~ \$xxx = \$xxx + 1 ;~ Until \$xxx = 10 ;~ EndIf ;~ ############# CAÍDA ############. Local \$Numtables_datos = 0 Next _ArrayDisplay(\$Datos_array, "Array display") _IEQuit(\$oIE) Thanks!!

monitoria.html

• Hi,
Google changed the style of translation page therefore _IEFormElementSetValue stopped working to set values in the google translator page automatically, I tried my best to fix it but it's not happening. It was working perfect a month ago almost before launching of new google translation interface. Any help would be highly appreciated...
I'm using a kind of function that help to set values in the form to google translator page and let it translate and then retrieve it back to save in a text file.
Here is my code:
#RequireAdmin #include <IE.au3> #include <String.au3> #include <Array.au3> #include <Excel.au3> #include <File.au3> ;*****************************Splitting Source Code Ended***************************** Local \$oExcel = _Excel_Open() Local \$oWorkbook1 = _Excel_BookOpen(\$oExcel, @ScriptDir & "\example.xlsx", False) ;*****************************Saving Software Links Started*************************** ;*****************************Splitting Source Code Started***************************** ;***************************************** Saving Title + .rar link + Description text file No. 1***************************** ProcessClose ( "iexplore.exe") \$file = fileopen(@ScriptDir & "\source.txt", 10) \$splitting = _Excel_RangeRead (\$oWorkbook1, Default, "A1") \$IE = _IECreate(\$splitting, 0, 0) \$source = _IEDocReadHTML(\$IE) FileWrite(\$file, \$source) \$target_source5 = _StringBetween(\$source, '</h1>', '<i>Скачать</i>') If Not @error Then FileWrite (@ScriptDir & "\kat01.txt", \$target_source5[0]) Sleep (50) ; removing of HTML codes to convert data into simple text \$File1 = @ScriptDir & "\kat01.txt" \$txt = FileRead(\$File1) \$txt = StringReplace(\$txt, "<br>", @crlf) \$txt = StringRegExpReplace(\$txt, '(?s)<a.*?</a>|<.*?>', "") \$txt = StringStripWS ( \$txt, \$STR_STRIPSPACES) \$txt = StringReplace(\$txt, "<br><", "") \$txt = StringReplace(\$txt, "--", "") \$txt = StringReplace(\$txt, "---", "") \$txt = StringReplace(\$txt, "&nbsp;", " ") \$txt = StringReplace(\$txt, "_", "") \$txt = StringReplace(\$txt, " ", "") FileWrite (@scriptdir & '\kat_saved.txt', \$txt) Local \$sFilePath = @ScriptDir & "\kat_saved.txt" ProcessClose ( "iexplore.exe") Example1() EndIf ;********************Example1 Function Written Started***************************** Func Example1() \$Text = FileRead (\$sFilePath) Local \$aArray = StringSplit(\$Text, @CR) For \$i = 1 To \$aArray[0] Local \$tag="* *" Local \$oIE=_IECreate("https://translate.google.com/#ru/en", 1, 1) \$HWND = _IEPropertyGet(\$oIE, "hwnd") WinSetState(\$HWND, "", @SW_MAXIMIZE) Sleep (500) Local \$oForm=_IEFormGetCollection(\$oIE,0) Local \$oQuery=_IEGetObjByName(\$oForm,"text") _IEFormElementSetValue(\$oQuery, \$tag & @CR & \$aArray[\$i] & @CR & \$tag) MouseMove ( 930, 275, 10) MouseClick ( "Main", 930, 275, 5, 10) Sleep(1000) MouseMove ( 930, 200, 10) MouseClick ( "Main", 930, 200, 5, 10) Sleep (10000) _IELoadWait(\$oIE) Local \$oText=_IEGetObjById(\$oIE,"gt-res-data") \$lines=StringSplit(_IEPropertyGet(\$oText,"innerText"),@CRLF,1) _IEQuit(\$oIE) ProcessClose ( "iexplore.exe") Sleep (1000) _ArrayDelete(\$lines,_ArraySearch(\$lines,\$tag,1,0,0,1,0) & "-" & \$lines[0]) _ArrayDelete(\$lines,"1-" & _ArraySearch(\$lines,\$tag,1,0,0,1,1)) \$lines[0]=UBound(\$lines)-1 \$FilePath = @ScriptDir & "\Translated.txt" \$arraytostring = _ArrayToString (\$lines) \$txt = StringReplace(\$arraytostring, "1|", "") \$txt = StringReplace(\$txt, "|", "") FileWrite (\$FilePath, \$txt & @CRLF) Next EndFunc ;MsgBox ('', 'Done Bro', 'Done Bro')
• By Jemboy
Yesterday I had to make some little changes to an old Autoit program we use at my work.
The program reads some data and convert it to Excel.
Before writing the cell, it is changed to text and later on I slap the column with an autofitwidth.
Furthermore weI execute a conditional format on the sheet, to make the data more readable.
I quickly found out that because of the breaking changes Excel.udf had starting from AutoIt 3.3.12.0,
a lot of things had to been changed.
The changes I had to do, only took 10 minutes.
After trying to adjust the script for over 5 hours, to get it working with the new Excel.udf, I gave up.
I stopped changing the script, uninstalled the my Autoit and went looking for an older version.
Luckilly I was able to find Autoit v3.3.8.1 (with corresponding Scite) in my software repository.
Installing Autoit V3.3.8.1 and compiling the file, now took me  10 minutes .

So why did I not get the old script working with the new Excel.udf?
There are several reasons I failed getting the old script working with the new Excel UDF.
I had some pressure from management to fix it ASAP (and got a little anxious)  Most all resources on the internet point to the working of the old EXcel.UDF And offcourse there were thosing "breaking changes",
with new functions using diffrent parameters or using parameters in different order. One of the column's on the sheet is used to store EAN13 (barcode) and was formatted like 1,23E12.
I couldn't change the cell to text, also autofitwidt was not working and using conditional formatting was also a no-no.
So in the end I could use the new Excel UDF, but not desapointed management.

What would I like to ask?
I understand that sometimes you want to rewrite a program to make it better. I even understand that one has to make breaking changes sometimes.
But in this case because of lacking examples/resources my day went completely down the drain.
I would like to ask the Excel.udf developpers to:
Make more functions available to do things like changing cell properties easily, changing cell color, do an autofit columnwidth, format data conditionally.
Or write an Example using the (new) Excel UDF, making examples how to format a cell, do conditional format, changing cell colors etc.
I probably am more of an example guy.
Having a good Excel.UDF Example showing a lot of common things normally makes, programming things easy for me.
Because I can keep tweaking snippets until I get it working the way I want it.

So dear developpers, could you help me and other future user out?

• I have a Word document containing a 9-column table where row 1 is the column headers. My goal is to read the table into a 2d array, remove some rows, update some fields, and add a few rows to the end. The resulting array will likely be a different length. Next, I want to write the data back into the table. If it's easier, I can write the data to a new document from a template containing the same table header with a blank 2nd row.
Here's my early attempt:
Local \$oWord = _Word_Create() Local \$oDoc = _Word_DocOpen(\$oWord, \$sFile) Local \$aData = _Word_DocTableRead(\$oDoc, 1) \$aData[3][5] = "Something else" Local \$oRange = _Word_DocRangeSet(\$oDoc, 0) \$oRange = _Word_DocRangeSet(\$oDoc, \$oRange, \$wdCell, 9) _Word_DocTableWrite(\$oRange,\$aData) This, unfortunately, writes the entire array into the first cell of row 2. What am I doing wrong?

• By Ascer
1. Description.
Udf working with MSDN System.Collections.ArrayList. Allow you to make fast operations on huge arrays, speed is even x10 better than basic _ArrayAdd.  Not prefered for small arrays < 600 items. 2. Requirements
.NET Framework 1.1 - 4.5 (on this version Microsoft destroy old rules) System Windows 3. Possibilities.
;=============================================================================================================== ; UDF Name: List.au3 ; ; Date: 2018-02-17, 10:52 ; Description: Simple udf to create System Collections as ArrayList and make multiple actions on them. ; ; Function(s): _ListCreate -> Creates a new list ; _ListCapacity -> Gets a list size in bytes ; _ListCount -> Gets items count in list ; _ListIsFixedSize -> Get bool if list if fixed size ; _ListIsReadOnly -> Get bool if list is read only ; _ListIsSynchronized -> Get bool if list is synchronized ; _ListGetItem -> Get item on index ; _ListSetItem -> Set item on index ; ; _ListAdd -> Add item at end of list ; _ListClear -> Remove all list items ; _ListClone -> Duplicate list in new var ; _ListContains -> Get bool if item is in list ; _ListGetHashCode -> Get hash code for list ; _ListGetRange -> Get list with items between indexs ; _ListIndexOf -> Get index of item ; _ListInsert -> Insert a new item on index ; _ListInsertRange -> Insert list into list on index ; _ListLastIndexOf -> Get index last of item ; _ListRemove -> Remove first found item ; _ListRemoveAt -> Remove item in index ; _ListRemoveRange -> Remove items between indexs ; _ListReverse -> Reverse all items in list ; _ListSetRange -> Set new value for items in range ; _ListSort -> Sort items in list (speed of reading) ; _ListToString -> Get list object name ; _ListTrimToSize -> Remove unused space in list ; ; Author(s): Ascer ;=============================================================================================================== 4. Downloads
List.au3 5. Examples
SpeedTest _ArrayAdd vs ListAdd SpeedTest ArraySearch vs ListIndexOf Basic usage - crating guild with members
×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...