Sign in to follow this  
Followers 0

Incremental Copy from Excel to IE Text Box

6 posts in this topic

#1 ·  Posted

Is this possible?

I've finished grabbing all the Obj in IE correctly, but I need a way to copy contents in an excel to specific text box in an IE Form.

This is the script I have so far for IE:

#include <IE.au3>
$sURL = "http://www.example.com"
Local $oIE = _IECreate ($sURL)
Local $oForm = _IEFormGetObjByName($oIE, "product_form")


Local $oSelectAttrVal = _IEGetObjById($oForm, "id_productattribute_set-0-value")
_IEFormElementSetValue($oSelectAttrVal, "")  ;; Text Box Identifier

I am able to just enter a string and have that text box filled, but I would like to basically do this following:

Create 10 x (loop this 10x) IE Window and enter into that Text Box (each instance different text) from Excel's Cell A1 to A10 into the 10 different IE Forms. Like A1 will be copied into the first IE Form, A10 will be copied into the 10th IE Form.

Or alternatively, if it's easier to code/script, from a plain text file Line 1 to Line 10.

Thanks in advance.

Share this post


Link to post
Share on other sites



#2 ·  Posted

For the loops check the FOR loop documentation. For the Excel part check the Excel UDF. It is similar to the IE UDF so you should have no probs there.

Share this post


Link to post
Share on other sites

#3 ·  Posted

For the loops check the FOR loop documentation. For the Excel part check the Excel UDF. It is similar to the IE UDF so you should have no probs there.

my concern is just I can have 2 #include right?

Do i put them right at the top in the first 2 row of my script?

Share this post


Link to post
Share on other sites

#5 ·  Posted

You can include more than one include, yes. And you want them at the top of your script, as they are interpreted first.

Ok. Cool I have everything working EXCEPT I can't stop the loop :oops:

Here is my code

#include <Excel.au3>
#include <File.au3>
#include <IE.au3>
Local $sFilePath = "C:UsersDocumentstest.xlsx"
_ExcelBookOpen($sFilePath)
$oExcel = _ExcelBookAttach($sFilePath)

For $i=1 to 7
$a = _ExcelReadCell($oExcel, $i, 1)
  
For $j=1 to 7
$b = _ExcelReadCell($oExcel, $j, 2)

For $k=1 to 7
$c = _ExcelReadCell($oExcel, $k, 4)

For $l=1 to 7
$d = _ExcelReadCell($oExcel, $l, 3)

For $m=1 to 7
$e = _ExcelReadCell($oExcel, $m, 5)


If $a="" Then ExitLoop

$sURL = "http://www.example.com/forms"
Local $oIE = _IECreate ($sURL)
Local $oForm = _IEFormGetObjByName($oIE, "product_form")


Local $oSelectBox1 = _IEGetObjByID($oForm, "id_box1")
_IEFormElementSetValue($oSelectBox1, $a)


Local $oSelectBox2 = _IEGetObjByID($oForm, "id_box2")
_IEFormElementSetValue($oSelectBox1, $b)


Local $oSelectBox3 = _IEGetObjByID($oForm, "id_box3")
_IEFormElementSetValue($oSelectBox1, $c)


Local $oSelectBox4 = _IEGetObjByID($oForm, "id_box4")
_IEFormElementSetValue($oSelectBox1, $d)


Local $oSelectBox5 = _IEGetObjByID($oForm, "id_box5")
_IEFormElementSetValue($oSelectBox1, $e)

Next
Next
Next
Next
Next

Need help stopping the loop after creating the 7 window :bye:... right now it's looping back to 1 >_>

Share this post


Link to post
Share on other sites

#6 ·  Posted

Because you have 4 nested loops. You need only one loop;

For $i=1 to 7

$a = _ExcelReadCell($oExcel, $i, 1)

$b = _ExcelReadCell($oExcel, $i, 2)

$c = _ExcelReadCell($oExcel, $i, 3)

$d = _ExcelReadCell($oExcel, $i, 4)

Local $oSelectBox1 = _IEGetObjByID($oForm, "id_box1")

_IEFormElementSetValue($oSelectBox1, $a)

Local $oSelectBox2 = _IEGetObjByID($oForm, "id_box2")

_IEFormElementSetValue($oSelectBox1, $:oops:

Local $oSelectBox3 = _IEGetObjByID($oForm, "id_box3")

_IEFormElementSetValue($oSelectBox1, $c)

Local $oSelectBox4 = _IEGetObjByID($oForm, "id_box4")

_IEFormElementSetValue($oSelectBox1, $d)

Next

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
Sign in to follow this  
Followers 0