MacBain00 Posted July 21, 2009 Share Posted July 21, 2009 I'm trying to activate a Sheet on an Excel File with the below code Non-working Code Local $sExcelSheets = "" Local $aExcelSheets = _ExcelSheetList($oExcel) If $switch = "SUAW" Then For $i = $aExcelSheets[0] To 1 Step -1 ;Work backwards through loop If StringInStr($aExcelSheets[$i], "Approv") Then ;Using the String Name returned in the Array Elements $sExcelSheets = $aExcelSheets[$i] EndIf If $sExcelSheets <> "" Then ExitLoop Next ElseIf $switch = "UserLoader" Then For $i = $aExcelSheets[0] To 1 Step -1 ;Work backwards through loop If StringCompare($aExcelSheets[$i],"Users")=0 Then ;Using the String Name returned in the Array Elements $sExcelSheets = $aExcelSheets[$i] EndIf If $sExcelSheets <> "" Then ExitLoop Next EndIf If $sExcelSheets = "" Then _ErrorProgressBar() MsgBox(0, "Error", " Unable to find the correct tab. ") Exit Else _ExcelSheetActivate($oExcel, $sExcelSheets) _Main() EndIf What's odd is that as standalone code it works without any errors (below). With the rest of my code I get the below error: $oExcel.Activesheet.Cells($sRangeOrRow, $iColumn).Value = $sValue $oExcel.Activesheet.Cells($sRangeOrRow, $iColumn).Value = $sValue^ ERROR Any help is appreciated. Working Temp Code #include <Excel.au3> #include <Array.au3> $oExcel = _ExcelBookOpen(@DesktopDir & "\Users.xls") Local $sExcelSheets = "" Local $aExcelSheets = _ExcelSheetList($oExcel) For $i = $aExcelSheets[0] To 1 Step -1 ;Work backwards through loop If StringCompare($aExcelSheets[$i],"Users")=0 Then ;Using the String Name returned in the Array Elements $sExcelSheets = $aExcelSheets[$i] EndIf If $sExcelSheets <> "" Then ExitLoop Next _ExcelSheetActivate($oExcel, $sExcelSheets) Exit -Work Smarter, Not Harder, Use More AutoIT Link to comment Share on other sites More sharing options...
nekkutta Posted July 21, 2009 Share Posted July 21, 2009 could it be you're using exitloop instead of continueloop? [size="2"] "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." - Brian Kernighan[/size] Link to comment Share on other sites More sharing options...
MacBain00 Posted July 21, 2009 Author Share Posted July 21, 2009 could it be you're using exitloop instead of continueloop?I ExitLoop if the Tab matches the name so that's working as expected. Plus it's the same in the standalone vs the bulk code. The standalone works as is.WEIRD -Work Smarter, Not Harder, Use More AutoIT Link to comment Share on other sites More sharing options...
MacBain00 Posted July 21, 2009 Author Share Posted July 21, 2009 Never mind guys. I put a few stops in and found that it's erroring in a totally different section. BUMP. -Work Smarter, Not Harder, Use More AutoIT 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