Jump to content

How To Code This???


Recommended Posts

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...