Tyw214 Posted March 19, 2012 Share Posted March 19, 2012 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. Link to comment Share on other sites More sharing options...
Juvigy Posted March 20, 2012 Share Posted March 20, 2012 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. Link to comment Share on other sites More sharing options...
Tyw214 Posted March 20, 2012 Author Share Posted March 20, 2012 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? Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted March 20, 2012 Moderators Share Posted March 20, 2012 You can include more than one include, yes. And you want them at the top of your script, as they are interpreted first. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Tyw214 Posted March 20, 2012 Author Share Posted March 20, 2012 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 Here is my code expandcollapse popup#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 ... right now it's looping back to 1 >_> Link to comment Share on other sites More sharing options...
Juvigy Posted March 21, 2012 Share Posted March 21, 2012 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, $ Local $oSelectBox3 = _IEGetObjByID($oForm, "id_box3") _IEFormElementSetValue($oSelectBox1, $c) Local $oSelectBox4 = _IEGetObjByID($oForm, "id_box4") _IEFormElementSetValue($oSelectBox1, $d) Next Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now