Chart error!

R

Roman

I have sales information in a data base, I put it in a Excell with out
problem, My boss wanted to see a chart and I did it with the next code.

Dim xlsApp As Excel.Application
Dim xlsCharts As Excel.Chart
…
Set xlsCharts = xlsApp.Application.Charts.Add
xlsCharts.Application.ActiveChart.chartType = 51
(*) xlsCharts.Application.ActiveChart.SetSourceData
Source:=Sheets("Sheet1").Range("A1: " & Chr(65 + Columna) & Str(Renglon -
1)), PlotBy:=xlColumns
ActiveChart.Location Where:=1

Every thing works at the first time, but when I want to run again the
process for another customer I get an error just in the line (*), Run time
error 1004 'Method 'Sheets' of objects '_Global' failed.
At the end of the function I have code to close the sheet and chart.

Set xlsCharts = Nothing
xlsBook.Close
Set xlsBook = Nothing
xlsApp.Quit

Do I have to close in different way the object charts?
Do I miss something?
Thank you for U help!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top