B
BilalD
Hello all
I am trying to add a chart as the very last sheet in a workbook. I have the
following VB 6.0 code. Using Excel 2003.
Option Explicit
Dim excelApp As New Excel.Application
Dim excelBook As Excel.Workbook
Dim excelSheet(0 To 3) As Excel.Worksheet
Dim excelchart(0 To 3) As Excel.Chart
Private Sub Command1_Click()
excelApp.Visible = True
Set excelBook = excelApp.Workbooks.Add
Set excelSheet(0) = excelBook.Worksheets.Add
With excelBook
..Sheets.Add After:=.Worksheets(Worksheets.Count), Type:=xlChart
End With
End Sub
What I notice is that even though I specify to add the chart after the very
last sheet, it already adds it right before the last. I didnt see anything in
the documentation that would lead me to believe that this is expect behavior.
I know I can move the chart to be the last sheet and thats how Im working
around this.
Did I just miss something? Can someone shed some light on this behavior? It
might have to do with adding sheets of different types, because I dont see
this happen if I add a WorkSheet instead of a chart.
I know im not the only one seeing this.
Thanks.
I am trying to add a chart as the very last sheet in a workbook. I have the
following VB 6.0 code. Using Excel 2003.
Option Explicit
Dim excelApp As New Excel.Application
Dim excelBook As Excel.Workbook
Dim excelSheet(0 To 3) As Excel.Worksheet
Dim excelchart(0 To 3) As Excel.Chart
Private Sub Command1_Click()
excelApp.Visible = True
Set excelBook = excelApp.Workbooks.Add
Set excelSheet(0) = excelBook.Worksheets.Add
With excelBook
..Sheets.Add After:=.Worksheets(Worksheets.Count), Type:=xlChart
End With
End Sub
What I notice is that even though I specify to add the chart after the very
last sheet, it already adds it right before the last. I didnt see anything in
the documentation that would lead me to believe that this is expect behavior.
I know I can move the chart to be the last sheet and thats how Im working
around this.
Did I just miss something? Can someone shed some light on this behavior? It
might have to do with adding sheets of different types, because I dont see
this happen if I add a WorkSheet instead of a chart.
I know im not the only one seeing this.
Thanks.