devchaminda Posted February 11, 2015 Share Posted February 11, 2015 (edited) Hi, When I running scenario_page.au3 page its gives following error message popup.Error opening workbook 'C:Dev_ChamindaQAAutomation_TestingTest_Data@error = 2, @extended = 0 System running read_excel_file.au3 page without an issue, when I run that page only. My code as below.expandcollapse popup;/////////////////;///////////////////////read_excel_file.au3;/////////////////;///////////////////////// #include <Array.au3> #include <Excel.au3> #include <MsgBoxConstants.au3> $sResult = Call("readexcel", "C:\Dev_Chaminda\QA\Automation_Testing\Test_Data\", "MyTest.xls", "Sheet1", "B", "2") MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example 1", $sResult) Func readexcel($filepath, $filename, $sheetval, $colnam, $rowval) ; Create application object and open an example workbook Local $oAppl = _Excel_Open(False) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended) Local $oWorkbook = _Excel_BookOpen($oAppl, $filepath & $filename, False, False, '', '') If @error Then MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example", "Error opening workbook '" & $filepath & @CRLF & "@error = " & @error & ", @extended = " & @extended) _Excel_Close($oAppl) Exit EndIf ; ***************************************************************************** ; Read data from a single cell on the active sheet of the specified workbook ; ***************************************************************************** Local $cellval = $colnam & $rowval Local $sResult = _Excel_RangeRead($oWorkbook, $sheetval, $cellval) ;_Excel_BookClose ( $oWorkbook,True) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example 1", "Error reading from workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended) Return $sResult EndFunc ;==>readexcel ;/////////////////;///////////////////write_excel_file.au3;/////////////////;////////////////////// #include <Array.au3> #include <Excel.au3> #include <MsgBoxConstants.au3> $sResult = Call("writexcel", "C:\Dev_Chaminda\QA\Automation_Testing\Test_Data\", "Test.xls", "Sheet1", "DEV", "A", "1") Func writexcel($filepath, $filename, $sheetval, $val, $colnam, $rowval) ; Create application object and open an example workbook Local $oAppl = _Excel_Open(False) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example", "Error creating the Excel application object." & @CRLF & "@error = " & @error & ", @extended = " & @extended) Local $oWorkbook = _Excel_BookOpen($oAppl, $filepath & $filename, False, False, '', '') If @error Then MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example", "Error opening workbook '" & $filepath & @CRLF & "@error = " & @error & ", @extended = " & @extended) _Excel_Close($oAppl) Exit EndIf ; ***************************************************************************** ; Read data from a single cell on the active sheet of the specified workbook ; ***************************************************************************** Local $range = $colnam & $rowval Local $sResult = _Excel_RangeWrite($oWorkbook, $sheetval, $val, $range) ;_Excel_BookClose ( $oWorkbook,True) If @error Then Exit MsgBox($MB_SYSTEMMODAL, "Excel UDF: _Excel_RangeRead Example 1", "Error reading from workbook." & @CRLF & "@error = " & @error & ", @extended = " & @extended) EndFunc ;==>writexcel ;/////////////////////////////my_login.au3;/////////////////;///////////////////////////// #include <IE.au3> #include <MsgBoxConstants.au3> Func openbrowser($serval, $hostval) Local $url = "http://" & $serval & "/" & $hostval & "/frmLogin.aspx" Global $oIE = _IECreate($url, 0, 1, 1, 1) _IELoadWait($oIE) EndFunc ;==>openbrowser Func IElogin($serval, $hostval, $myusr, $mypass) Local $url = "http://" & $serval & "/" & $hostval & "/frmLogin.aspx" _IENavigate($oIE, $url) _IELoadWait($oIE) Local $usr = _IEGetObjByName($oIE, "ctl00$cphMainContent$txtUserName") Local $psr = _IEGetObjByName($oIE, "ctl00$cphMainContent$txtPassword") _IEFormElementSetValue($usr, $myusr) _IEFormElementSetValue($psr, $mypass) Send("{ENTER}") _IELoadWait($oIE) Return $myusr & ", Successfully login." EndFunc ;==>IElogin Func IElogout($serval, $hostval) Local $url = "http://" & $serval & "/" & $hostval & "/frmLogin.aspx" _IENavigate($oIE, $url) _IELoadWait($oIE) _IEQuit($oIE) Return "Successfully logout." EndFunc ;==>IElogout Func closebrowser() _IEQuit($oIE) Return "Close browser." EndFunc ;==>closebrowser ;/////////////////;/////////////////////scenario_page.au3;///////////////////////////// #include <IE.au3> #include <MsgBoxConstants.au3> #include <write_excel_file.au3> #include <read_excel_file.au3> #include <my_login.au3> #include <Array.au3> #include <Excel.au3> Local $serval = Call("readexcel", "C:\Dev_Chaminda\QA\Automation_Testing\Test_Data\", "MyTest.xls", "Sheet1", "B", "2") Local $hostval = Call("readexcel", "C:\Dev_Chaminda\QA\Automation_Testing\Test_Data\", "MyTest.xls", "Sheet1", "C", "2") Local $usr = Call("readexcel", "C:\Dev_Chaminda\QA\Automation_Testing\Test_Data\", "MyTest.xls", "Sheet1", "D", "2") Local $psr = Call("readexcel", "C:\Dev_Chaminda\QA\Automation_Testing\Test_Data\", "MyTest.xls", "Sheet1", "E", "2") Call("openbrowser", $serval, $hostval) Local $res = Call("IElogin", $serval, $hostval, $usr, $psr) Call("IElogout", $serval, $hostval) Call("closebrowser") Call("writexcel", "C:\Dev_Chaminda\QA\Automation_Testing\Test_Data\", "MyTest.xls", "Sheet1", $res, "F", "2") ;/////////////////;/////////////////;/////////////////;/////////////////;/////////////////////////// Edited February 11, 2015 by Melba23 Added code tags Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted February 11, 2015 Moderators Share Posted February 11, 2015 devchaminda,Welcome to the AutoIt forums. When you post code please use Code tags - see here how to do it. Then you get a scrolling box and syntax colouring as you can see above now I have added the tags. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted February 11, 2015 Moderators Share Posted February 11, 2015 The error message is telling you the problem, @error = 2 on _Excel_BookOpen means it cannot find the file. Make sure the file is where you think it is in your directory structure. If you want more than this, you're going to have to provide full code, including your custom includes, or a pared down reproducer that removes these functions. "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...
water Posted February 11, 2015 Share Posted February 11, 2015 No need to use "Call". ; $sResult = Call("readexcel", "C:\Dev_Chaminda\QA\Automation_Testing\Test_Data\", "MyTest.xls", "Sheet1", "B", "2") $sResult = readexcel("C:\Dev_Chaminda\QA\Automation_Testing\Test_Data\", "MyTest.xls", "Sheet1", "B", "2") My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
devchaminda Posted February 12, 2015 Author Share Posted February 12, 2015 Hi All, Its working after i create a new scenario page. Thanks Melba23 and thank others as well. I am planing to automate web application using AutoIT and its kind of pilot project(find a alternative for Selenium). I get to know this tool in 2011, but now i see may improvement. Since this is an free tool this has very good help file and its really impressive, that lets me to use this tool now and really great-full to thanks every one who gave their contribution to take this tool up to this level. .................. Thanks Dev chaminda 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