S
Steve T
I have a script which creates an excel workbook, dumps a load of data into
it and calls the following code. The ranges are created from a query and
relate to the data that has just been added to the workbook.
xlApplication.Sheets("Sheet1").Select
xlApplication.ActiveSheet.Range("A1:A10,C1:C10110,F1:F10").Select
xlApplication.Charts.Add
xlApplication.ActiveChart.SetSourceData
xlApplication.Sheets("Sheet1").Range("A1:A10,C1:C10110,F1:F10"), 2
xlApplication.ActiveChart.Location 1
xlApplication.ActiveChart.HasDataTable = True
xlApplication.ActiveChart.DataTable.ShowLegendKey = True
xlApplication.ActiveChart.HasTitle = True
xlApplication.ActiveChart.ChartTitle.Characters.Text = strGraphTitle
xlApplication.ActiveChart.DisplayBlanksAs = 3
xlApplication.ActiveChart.PlotVisibleOnly = True
xlApplication.ActiveChart.Name = strChartTabName
A1:A10 contain the x-axis data and the rest of the ranges are plotted on the
chart. All ranges are of the same type [i.e. number or currency or time
etc...]
The excel file is then saved and opened in a web browser.
At first I thought that it was working really well, but excel gets confused
when the data is in a time format. For some reason this screws up the chart.
Closer inspecting shows that the data ranges are overridden and the chart is
meaningless.
Strangely, if I record a macro in excel [which produces equivalent vb code]
that plots the same chart on the data I get the same result.
Could this be a quirk of excel or is there something glaringly obvious that
I have missed.
Many thanks in advance.
Steve
it and calls the following code. The ranges are created from a query and
relate to the data that has just been added to the workbook.
xlApplication.Sheets("Sheet1").Select
xlApplication.ActiveSheet.Range("A1:A10,C1:C10110,F1:F10").Select
xlApplication.Charts.Add
xlApplication.ActiveChart.SetSourceData
xlApplication.Sheets("Sheet1").Range("A1:A10,C1:C10110,F1:F10"), 2
xlApplication.ActiveChart.Location 1
xlApplication.ActiveChart.HasDataTable = True
xlApplication.ActiveChart.DataTable.ShowLegendKey = True
xlApplication.ActiveChart.HasTitle = True
xlApplication.ActiveChart.ChartTitle.Characters.Text = strGraphTitle
xlApplication.ActiveChart.DisplayBlanksAs = 3
xlApplication.ActiveChart.PlotVisibleOnly = True
xlApplication.ActiveChart.Name = strChartTabName
A1:A10 contain the x-axis data and the rest of the ranges are plotted on the
chart. All ranges are of the same type [i.e. number or currency or time
etc...]
The excel file is then saved and opened in a web browser.
At first I thought that it was working really well, but excel gets confused
when the data is in a time format. For some reason this screws up the chart.
Closer inspecting shows that the data ranges are overridden and the chart is
meaningless.
Strangely, if I record a macro in excel [which produces equivalent vb code]
that plots the same chart on the data I get the same result.
Could this be a quirk of excel or is there something glaringly obvious that
I have missed.
Many thanks in advance.
Steve