Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

Incremental Copy from Excel to IE Text Box


  • Please log in to reply
5 replies to this topic

#1 Tyw214

Tyw214

    Seeker

  • Active Members
  • 8 posts

Posted 19 March 2012 - 10:33 PM

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 = "<a href='http://www.example.com' class='bbc_url' title='External link' rel='nofollow external'>http://www.example.com"</a> 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.







#2 Juvigy

Juvigy

    Experimental Drugs Abuser

  • Active Members
  • PipPipPipPipPipPip
  • 1,282 posts

Posted 20 March 2012 - 07:42 AM

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.

#3 Tyw214

Tyw214

    Seeker

  • Active Members
  • 8 posts

Posted 20 March 2012 - 02:03 PM

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?

#4 JLogan3o13

JLogan3o13

    115 and holding

  • MVPs
  • 4,433 posts

Posted 20 March 2012 - 02:53 PM

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

If you put a million monkeys on a million keyboards, one of them will eventually write a Java program. The rest of them will write Perl programs.

 

My Scripts: SCCM UDFInclude Source with Compiled Script, Disk Maintenance for Windows XP, "Deal-A-Day" Sites, Windows Firewall UDF


#5 Tyw214

Tyw214

    Seeker

  • Active Members
  • 8 posts

Posted 20 March 2012 - 03:43 PM

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

Plain Text         
#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 = "<a href='http://www.example.com/forms' class='bbc_url' title='External link' rel='nofollow external'>http://www.example.com/forms"</a> 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 >_>

#6 Juvigy

Juvigy

    Experimental Drugs Abuser

  • Active Members
  • PipPipPipPipPipPip
  • 1,282 posts

Posted 21 March 2012 - 07:45 AM

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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users