Andy2520 Posted August 7, 2014 Share Posted August 7, 2014 (edited) Dear Team, I am creating one script it should read the content of Ms excel cell if content is there script should process .If content is not there in cell script should exit with msg box . Here is the code .could you please help me in the same . #include <Excel.au3> #include <MsgBoxConstants.au3> Local $oExcel = _ExcelBookOpen("d:\ani.xls",0) ;Local $oExcel = _ExcelBookNew() ;Create new book, make it visible ;For $i = 1 To 5 ;Loop ; _ExcelWriteCell($oExcel, $i, $i, 1) ;Write to the Cell ;Next Local $sCellValue, $sCellValue1 ,$splitsrname1,$splitsrnameyear,$splitsrnamedate,$splitsrnamemonth,$splitsrnamemonth1 For $i = 2 To 3 ;Loop $sCellValue = _ExcelReadCell($oExcel, $i, 1) $sCellValue1 = _ExcelReadCell($oExcel, $i, 2) $splitsrname1 = StringLeft($sCellValue1, 8) $splitsrnameyear = StringLeft($splitsrname1,4) $splitsrnamedate = Stringright($splitsrname1,2) $splitsrnamemonth =Stringright($splitsrname1,4) $splitsrnamemonth1 =StringLeft($splitsrnamemonth,2) dim $DOB =$splitsrnamedate&$splitsrnamemonth1&$splitsrnameyear MsgBox($MB_SYSTEMMODAL, "", "The Cell Value is: " & @CRLF & $sCellValue, 2) MsgBox($MB_SYSTEMMODAL, "", "The Cell Value is: " & @CRLF & $splitsrnameyear , 2) MsgBox($MB_SYSTEMMODAL, "", "The Cell Value is: " & @CRLF & $splitsrnamedate , 2) MsgBox($MB_SYSTEMMODAL, "", "The Cell Value is: " & @CRLF & $splitsrnamemonth1 , 2) MsgBox($MB_SYSTEMMODAL, "", "The Cell Value is: " & @CRLF & $DOB, 2) if $sCellValue =" " then MsgBox($MB_SYSTEMMODAL, "test", "there is no data in cell now exit") Exit EndIf Next Edited August 7, 2014 by Andy2520 Link to comment Share on other sites More sharing options...
water Posted August 7, 2014 Share Posted August 7, 2014 Doesn't look bad. What doesn't work? My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Andy2520 Posted August 7, 2014 Author Share Posted August 7, 2014 Thanks Water for your reply!! . if one cell is empty or doesnot have any content it should exit the script .in above code script reading till last cell i.e For $i = 2 To 3. I need as soon as if get empty value frm cell it should exit . Link to comment Share on other sites More sharing options...
water Posted August 7, 2014 Share Posted August 7, 2014 (edited) Could you test for cells with no content ("")? Now you test for cells with a space as content: if $sCellValue = "" then Edited August 7, 2014 by water My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki Link to comment Share on other sites More sharing options...
Andy2520 Posted August 7, 2014 Author Share Posted August 7, 2014 Thanks Water So sorry i have asked stupid help ..Simple issue . tried its working fine .. thank you so much Link to comment Share on other sites More sharing options...
water Posted August 7, 2014 Share Posted August 7, 2014 My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki 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