Mecrazycoder Posted September 9, 2009 Posted September 9, 2009 (edited) Hi Guys, I wrote a script to open Excel file. #Include<Excel.au3> $oExcel=_ExcelBookOpen("TableInput.xls") $sheetNameList=_ExcelSheetList($oExcel) For $i=1 To $sheetNameList[0] MsgBox(0,"",$sheetNameList[$i]) Next but the problem when i run it i am getting error as F:\Tools\AutoIt3\Include\Excel.au3 (189) : ==> The requested action with this object has failed.: If $sPassword = "" And $sWritePassword = "" Then .WorkBooks.Open($sFilePath, Default, $fReadOnly) If $sPassword = "" And $sWritePassword = "" Then .WorkBooks.Open($sFilePath, Default, $fReadOnly)^ ERROR Is there anything wrong with my code.File is not password protected.Tanx in advance Edited September 9, 2009 by Mecrazycoder [size="4"][font="Arial Narrow"][font="Garamond"]Attitude is a little thing that makes a big difference[/font][/font][/size][indent][/indent]
Juvigy Posted September 9, 2009 Posted September 9, 2009 this line is completely wrong: For $i=1 To $sheetNameList[0] change it to: For $i=0 To Ubound($sheetNameList)-1 step 1
Mecrazycoder Posted September 9, 2009 Author Posted September 9, 2009 this line is completely wrong: For $i=1 To $sheetNameList[0] change it to: For $i=0 To Ubound($sheetNameList)-1 step 1 Tanx man but i am afraid its not working.Any way without loop also i am getting same error [size="4"][font="Arial Narrow"][font="Garamond"]Attitude is a little thing that makes a big difference[/font][/font][/size][indent][/indent]
Juvigy Posted September 9, 2009 Posted September 9, 2009 Specify the full path to the excel file and try again. Also check with IsObj($oExcel) if the open function has succeeded.
Mecrazycoder Posted September 9, 2009 Author Posted September 9, 2009 Specify the full path to the excel file and try again.Also check with IsObj($oExcel) if the open function has succeeded.After giving full path it seems to be working.But i am not sure,why that error occurred before, though the file is in script directory.Anyway its working now.Tanx dude [size="4"][font="Arial Narrow"][font="Garamond"]Attitude is a little thing that makes a big difference[/font][/font][/size][indent][/indent]
Juvigy Posted September 9, 2009 Posted September 9, 2009 The function need full path name: #Include <Excel.au3> $oExcel = _ExcelBookOpen($sFilePath[, $fVisible = 1[, $fReadOnly = False[, $sPassword = ""[, $sWritePassword = ""]]]]) Parameters $sFilePath Path and filename of the file to be opened $fVisible Flag, whether to show or hide the workbook (0=not visible, 1=visible) (default=1) $fReadOnly Flag, whether to open the workbook as read-only (True or False) (default=False) $sPassword The password that was used to read-protect the workbook, if any (default is none) $sWritePassword The password that was used to write-protect the workbook, if any (default is none)
Mecrazycoder Posted September 9, 2009 Author Posted September 9, 2009 The function need full path name: #Include <Excel.au3> $oExcel = _ExcelBookOpen($sFilePath[, $fVisible = 1[, $fReadOnly = False[, $sPassword = ""[, $sWritePassword = ""]]]]) Parameters $sFilePath Path and filename of the file to be opened $fVisible Flag, whether to show or hide the workbook (0=not visible, 1=visible) (default=1) $fReadOnly Flag, whether to open the workbook as read-only (True or False) (default=False) $sPassword The password that was used to read-protect the workbook, if any (default is none) $sWritePassword The password that was used to write-protect the workbook, if any (default is none) Umm..that sounds gud Tanx dude [size="4"][font="Arial Narrow"][font="Garamond"]Attitude is a little thing that makes a big difference[/font][/font][/size][indent][/indent]
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