in reply to Re: Deleting Blank worksheets
in thread Deleting Blank worksheets

I am sorry monks...My bad... I am using Win32::OLE...and this is the way i am creating new worksheets..
if($a==1) { $sheet3= $workbook->Worksheets->Add( {after => $workbook->Worksheets($workbook->Worksheets->{count})} ); }
Now what i am doing is retrieving information from database and putting them into different worksheets depending upon the type of information sought. as i said..at the end of my script..there is always a blank sheet left..and whenever i re run the script.another blank sheet gets added to my file. So i thought that if at the end of the script i delete this sheet then..All i would have is the sheets in which information is stored. I hope i have successfully given you the info u need... I appreciate you guys taking out your time for me..Thanks!

Replies are listed 'Best First'.
Re^3: Deleting Blank worksheets
by jrsimmon (Hermit) on Dec 04, 2007 at 19:48 UTC
    Because you are getting a new worksheet added each time your script runs, and the worksheet name is steadily counting up (sheet1, sheet2, ...), I think it is more likely that you are inadvertently adding one more sheet than you intended. Unfortunately, that would require you posting more of your code for us to confirm...

    You could go about it by running through your script and then traversing again all of the worksheets in the workbook, deleting any that you don't want...but why not prevent the unnecessary one from being created in the first place?

    So, more code please, and I'll take a look. Try to consolidate it as much as possible while still exhibiting the problem...then post the entire example script.