in reply to Deleting Blank worksheets

Hello Ashes, and welcome. Please read I want to ask a question of the Perl Monks. Where do I start? to learn about posting your questions more effectively.

Given the information you've provided, it's really hard to know whether you're dealing with the default worksheet names created when a new workbook is opened, or if you're creating these unwanted worksheets through some other method. It may help you to look through RFC: Win32::OLE and Excel's RefreshAll that shows how to spin through all worksheets within a workbook checking a property in each.

After reading the posting guidelines linked above, please update your original question with a code example and I will try to be of further assistance.

Replies are listed 'Best First'.
Re^2: Deleting Blank worksheets
by Ashes.cfg (Initiate) on Dec 04, 2007 at 19:33 UTC
    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!
      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.