Worksheet delete problem 
Author Message
 Worksheet delete problem

Can anyone tell me why the following VB6 code does not delete the first
sheet in the workbook?
It should do.

Dim xlSummary as New Excel.Application
Dim wkbSummary as Excel.Workbook

Set xlSummary = New Excel.Application
xlSummary.Workbooks.Open filename.xls
Set wkbSummary = xlSummary.ActiveWorkbook
wkbSummary.Worksheets(1).Delete

I am running VB6 and MS Offixe XP under WinXP Pro,
and yes the project does reference the MS Excel 10.0 Object Library



Thu, 08 Jul 2004 15:46:40 GMT  
 Worksheet delete problem
Try This:
Sub Macro1()
  Dim xlSummary As Workbook
  Dim wkbSummary As Worksheet
  Set xlSummary = ActiveWorkbook
  Set wkbSummary = xlSummary.Worksheets(1)
  wkbSummary.Delete
End Sub
Quote:
>-----Original Message-----
>Can anyone tell me why the following VB6 code does not
delete the first
>sheet in the workbook?
>It should do.

>Dim xlSummary as New Excel.Application
>Dim wkbSummary as Excel.Workbook

>Set xlSummary = New Excel.Application
>xlSummary.Workbooks.Open filename.xls
>Set wkbSummary = xlSummary.ActiveWorkbook
>wkbSummary.Worksheets(1).Delete

>I am running VB6 and MS Offixe XP under WinXP Pro,
>and yes the project does reference the MS Excel 10.0
Object Library

>.



Thu, 08 Jul 2004 16:58:53 GMT  
 Worksheet delete problem
?????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????


Thu, 08 Jul 2004 17:39:38 GMT  
 Worksheet delete problem

    That's a pretty tough question, mate. Don't know if I have an answer.

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *


????????????????????????????????????????????????????????????????????????????
?????????????????????????????????????????????????????????



Thu, 08 Jul 2004 18:23:03 GMT  
 Worksheet delete problem
Before Excel deletes a sheet, it puts up a warning dialog asking if you are
sure.  Did you account for this?

Also, at least one sheet must be in the workbook - is this a one sheet
workbook?

Regards,
Tom Ogilvy


Quote:
> Can anyone tell me why the following VB6 code does not delete the first
> sheet in the workbook?
> It should do.

> Dim xlSummary as New Excel.Application
> Dim wkbSummary as Excel.Workbook

> Set xlSummary = New Excel.Application
> xlSummary.Workbooks.Open filename.xls
> Set wkbSummary = xlSummary.ActiveWorkbook
> wkbSummary.Worksheets(1).Delete

> I am running VB6 and MS Offixe XP under WinXP Pro,
> and yes the project does reference the MS Excel 10.0 Object Library



Fri, 09 Jul 2004 01:53:03 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Problems deleting a worksheet via automation

2. Problems deleting a worksheet via automation

3. Delete Worksheet Problem

4. Deleting Worksheet Problem

5. problems deleting a named referance in a worksheet

6. problems making a copy of a worksheet that's a copy of another worksheet

7. event copying worksheet 1 to worksheet 2.....problem

8. Spell Check, auto delete Deleted ... other problems

9. Deleting XL worksheets

10. Macro to delete worksheets automatically


 
Powered by phpBB® Forum Software © phpBB Group