Santana Posted September 23, 2009 Share Posted September 23, 2009 Hi all, i have the following script and am willing to open several excel spreadsheets, delete the first two rows, save the canges and close. For some reason, it open the files but do not delete the rows. Can anyone tell me what am I doing wrong? Thanks in advance. #Include <Excel.au3> $path = @ScriptDir & "\input\" $file = FileFindFirstFile($path & "\*.*") if $file = -1 then msgbox(496, "File not found") while 1 $ExcelFile = FileFindNextFile($file) if $ExcelFile ="" then exitloop ExcelRowDelete($path, $excelfile) WEnd func ExcelRowDelete($loc, $oExcel) $workbook = $loc & $oExcel _ExcelBookOpen($workbook) processwait("EXCEL.EXE") _ExcelColumnDelete($oExcel, 1, 2) Sleep(50) _ExcelBookClose($oExcel, 1, 0) ProcessWaitClose("EXCEL.EXE") EndFunc Just another special date with a different challenge Link to comment Share on other sites More sharing options...
PsaltyDS Posted September 23, 2009 Share Posted September 23, 2009 By convention, the "o" in $oExcel means it's an Obj type (COM Object). You are passing a string file name in it and then trying to use that string in place of the object reference returned by _ExcelBookOpen(). Try this: Func ExcelRowDelete($loc, $sExcel) Local $workbook = $loc & $sExcel Local $oExcel = _ExcelBookOpen($workbook) ProcessWait("EXCEL.EXE") _ExcelColumnDelete($oExcel, 1, 2) Sleep(50) _ExcelBookClose($oExcel, 1, 0) ProcessWaitClose("EXCEL.EXE") EndFunc ;==>ExcelRowDelete Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Santana Posted September 24, 2009 Author Share Posted September 24, 2009 Thanks a million. Just another special date with a different challenge 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