Sign in to follow this  
Followers 0
Santana

Problem with Excel

3 posts in this topic

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

Share this post


Link to post
Share on other sites



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

:D


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

Share this post


Link to post
Share on other sites

Thanks a million.


Just another special date with a different challenge

Share this post


Link to post
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
Sign in to follow this  
Followers 0