Piyush Posted July 14, 2009 Share Posted July 14, 2009 Please Give me code for this job: when script starts if @scriptdir&"\"data.xls exists then open it if not then open a new excel file when script closes then if data.xls file exists then simply save and close the file if file doesnot exists then save the opened excel file with name data.xls in the script dir i had tried this If FileExists(@ScriptDir&"\Data.xls") Then $excel=_ExcelBookOpen(@ScriptDir&"\Data.xls",1) Else $excel=_ExcelBookNew() EndIf Func Close() If FileExists(@ScriptDir&"\Data.xls") Then _ExcelBookClose($excel) Else _ExcelBookSaveAs($excel,@ScriptDir&"\Data.xls") _ExcelBookClose($excel) EndIf Exit EndFunc but it doesnot works it gives this error Line 185 (File "C:\Program Files\AutoIt3\Beta\Include\Excel.au3"): If $sPassword = "" And $sWritePassword = "" Then .WorkBooks.Open($sFilePath, Default, $fReadOnly) If $sPassword = "" And $sWritePassword = "" Then .WorkBooks.Open($sFilePath, Default, $fReadOnly)^ ERROR Error: The requested action with this object has failed. [font="Comic Sans MS"][size="7"]Piyush.....[/size][/font][font="Palatino Linotype"][size="2"]Some Of My Scripts...Cool Font Generator Train Searcher and Tracer[/size][/font] Link to comment Share on other sites More sharing options...
trung0407 Posted July 14, 2009 Share Posted July 14, 2009 before the point of .WorkBooks.Open you forgot smt... I should be $object.WorkBooks.Open or smt like that 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