Malpario Posted August 22, 2011 Share Posted August 22, 2011 (edited) UPDATE - decided to close this as no response has been given---------------------------------------------------------------------------------- Please forgive me if the code is sloppy. Also, I've changed the name of the website and User/Pass for security reasons. I currently have a script that does the following: Opens an excel file and copies the account numbers to an arrayIt saves the array to a text file and then prints it for the user.Next, it logs on to a website and asks the user how many accounts to “update”. If the user enters 20, it will loop 20 times for 20 account numbers.It then chooses the first account number, goes through several frames and object IDs and updates the webpage with the account number from the array.Next, it chooses the next account number and does the same.This will continue until it reaches the number the client entered in step 3 (this is how many accounts to update).Last, it quits the scripts and closes IE. The problem I have is that sometimes, in the middle of updating the account, the script errors out, with different errors, and the script stops. If the user is not watching every account update, they will not know where to begin from. How do I insert some kind of error within the scripts that notifies the user at what account it error out at. This way, the user can go into the spreadsheet, remove the accounts already updated, and restart the script? Attached is the "sloppy" code expandcollapse popup#include <File.au3> #include <Array.au3> #include <Excel.au3> #include <IE.au3> #include <Date.au3> ;----------------------------------------------------------------------------- ;Open Excel and sets up the Array - Moves the files to Current Folder ;----------------------------------------------------------------------------- local $oExcel = _ExcelBookOpen("C:\BBWK\export1CA.xls") $aArray1 = _ExcelReadSheetToArray($oExcel,2,3,0,1) _ExcelBookClose($oExcel) ;~ _ArrayDisplay ($aArray1, "array") $content = "" $file = "C:\arrayCA.txt" FileClose(FileOpen($file, 2)) ;create the file For $i=1 To UBound($aArray1)-1 $content &= $aArray1[$i][1]&@CRLF Next FileWrite($file, $content) ;~ MsgBox(0, "", "array was written to text file ") _Fileprint("C:\arrayCA.txt") Sleep (2000) FileDelete("C:\arrayCA.txt") ;~ FileMove("C:\BBWK\Export1CA.xls", "C:\BBWK\Current\Export1CA.xls", 1) ;~ FileMove("C:\BBWK\Export.csv", "C:\BBWK\Current\Export.csv", 1) ;~ Sleep (5000) ;~ Run("C:\BBWK\Scripts\Current\CA-DATE.bat") ;~ Sleep (1000) Sleep (2000) ;----------------------------------------------------------------------------- ;Log in In to Sagent Website ;----------------------------------------------------------------------------- Opt("WinTitleMatchMode", 2) $oIE = _IECreate ("Sagent Website") $o_frame = _IEFrameGetObjByName ($oIE, "launcher") $o_login = _IEGetObjById ($o_frame, "SaPrincipalName") $o_password = _IEGetObjById ($o_frame, "SaPrincipalPassword") $o_Input = _IEGetObjById($o_Frame, "SaRepositoryName") $username = "Temp" $password = "Temp" _IEFormElementSetValue ($o_login, $username) _IEFormElementSetValue ($o_password, $password) _IEFormElementOptionselect ($o_Input, "SARPSERV" , 1, "byText") $oInputs = _IETagNameGetCollection ($o_Frame, "input") For $oInput In $oInputs If $oInput.value = "Log In" Then ExitLoop EndIf Next _IEAction($oInput, "click") Sleep (5000) ;----------------------------------------------------------------------------- ;Click on Update Customer Link and choose Handle (BWK-SANFR, BWK-PORTL or BWK-BOSTN) ;Submits the account number from the array ;Continues to loop until the last account is entered. ;----------------------------------------------------------------------------- _IELinkClickByIndex ($o_frame, 0);Clicks on "v-pick/update customers" Link Sleep (6000) ;Allows time (6 seconds) to load the page $value = InputBox("Value", "Enter value", "0");asks for how many accounts to update. Do $i=$value For $r=1 To UBound($aArray1,1)-1 $o_frame = _IEFrameGetObjByName ($oIE, "launcher") Sleep (300) $oFrameB = _IEFrameGetObjByName($oIE, "target" ) Sleep (300) $oFrameC = _IEFrameGetObjByName($oFrameB, "results") Sleep (300) $o_Input1 = _IEGetObjById($oFrameC, "SaProperty.NewHndlgCd"); Chooses the correct Handling Code, either BWK-SANFR, BWK-PORTL or BWK-BOSTN Sleep (300) $o_Input2 = _IEGetObjById($oFrameC, "SaProperty.AcctNbr");Enters account number in Account Number Box Sleep (1000) _IEFormElementOptionselect ($o_Input1, "BWK-SANFR" , 1, "byText") ; Tells the script which Handle to default to, either BWK-SANFR, BWK-PORTL or BWK-BOSTN Sleep (1000) For $c=1 to UBound($aArray1,2)-1 $aVariable = $aArray1[$r][$c] $Account = ($aVariable) _IEFormElementSetValue ($o_Input2, $Account) Sleep (500) $oInputs1 = _IETagNameGetCollection ($oFrameC, "input") Sleep (500) For $oInput1 In $oInputs1 If $oInput1.value = "Submit" Then ExitLoop EndIf Next Sleep (500) _IEAction($oInput1, "click") Sleep (5000) WinActivate ("Sagent WebLink - Windows Internet Explorer") Sleep (2000) _IELinkClickByIndex ($o_frame, 0);Update Customer Link Sleep (2000) Next Next Until $i = $value Winkill ("Sagent WebLink - Windows Internet Explorer") Exit Edited September 19, 2011 by Malpario 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