Hi Cindy,
Thanks for the advise - I had already tried to copy the kinds of code Excel produces but without much joy. As you can see in ther example below I have added a chart in a sheet - however, I am then unable to access it. I get messges of Invalid Index - or messages about not being able to set class properties.
If you have an example of code that puts an Excel chart into an Excel Sheet and formats it programatically I would appreciate it.
Basically the aim of this is to produce a spreadsheet summarising electricity consumption for a site - as a batch process creating, printing and saving the XLS spreadsheet for later use.
appOLE = CREATEOBJECT("Excel.Application")
appOLE.Visible = .t.
appOLE.Cells(11,3).Value = "Maximum Demand (kW)"
appOLE.Cells(11,4).Value = "Maximum Demand (Date)"
appOLE.Cells(11,5).Value = "Maximum Demand (Time)"
appOLE.Cells(11,6).Value = "Load Factor (%)"
appOLE.Cells(11,7).Value = "Day Consumption (kWh)"
appOLE.Cells(11,8).Value = "Night Consumption (kWh)"
appOLE.Cells(11,9).Value = "Night Proportion (%)"
appOLE.Cells(11,10).Value = "Total Consumption"
appOLE.Cells(11,11).Value = "Monthly Proportion (%)"
* Below here is where I run into problems. If I add code from Excel I get Servers threw up an exception.
appOLE.Worksheets("sheet1").ChartObjects.Add(100, 30, 400, 250)
appOLE.Charts(1).Chart(1).HasTitle = .t.
I can see from the NT task manager the problems of lots of Excel instances running if you don't make the app visible!!!
If only everything in life was as reliable as VFP