Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with MS Excel Chart Objects

Status
Not open for further replies.

apkohn

Technical User
Nov 27, 2000
62
AU
I am writing a VB5 app that sends output to an Excel 97 spreadsheet, and then creates a chart from the data. As the process takes quite some time to complete, and knowing how users are very impatient, I have (where practicable) avoided all references to Activesheet, Selection etc... and have tried to program with absolute references

So I have m_xlOutput.Charts(1) instead of m_xlOutput.ActiveCharts

This is where the problem arises.

I have two sheets in the spreadsheet, "Inputs" and "Outputs". I then add a chart (charts.add), add the series, and format it. By default the Add method creates the chart as a new sheet, so I need to move it to an object on the sheet "Outputs", so I use the:
..Charts(1).Location xlLocationAsObject, "Outputs"
This behaves strangely, and moves the chart to the "Inputs" page, but more disturbingly, removes the chart from the Charts collection. Thus Charts(1) now no longer exists.

So the question really is, (1) how do you refer to a chart object, that is an object on a sheet, and (2) why is the Location method moving the chart to the wrong sheet

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top