PDA

For continued disscussion on this topic : Visual Basic Action script



Chopper
06-25-2001, 02:16 PM
Hey everyone, I have a problem which is getting on my nerves, I need to create a graph in excel using a macro, I do it with this code



Range("F59:J60").Select
Charts.Add
ActiveChart.ChartType = xl3DPieExploded
ActiveChart.SetSourceData Source:=Sheets("The questionnaire").Range("F59:J60" _
), PlotBy:=xlRows
ActiveChart.Location Where:=xlLocationAsObject, Name:="The questionnaire"
With ActiveChart
.HasTitle = True
.ChartTitle.Characters.Text = "Question 3:"
End With
ActiveChart.ApplyDataLabels Type:=xlDataLabelsShowPercent, LegendKey:=False _
, HasLeaderLines:=True

And it doesnt seem to be working it seems to find a problem with the charts.add part, is there any reason for this, I have even copied an example from the text book and it still will not work, please help me in my time of need.

gzazJim
06-25-2001, 05:03 PM
hey truss2001,

Have ou tried moving the Charts.Add to the end of the function? I think it's trying to add an object that doens't yet exist perhaps?

Regards,

Jim

Chopper
06-25-2001, 11:01 PM
I found the problem :o
I had protect the spreadsheet and so it had took certain functions away such as chart.add, Whats the point in that, if you want people to see your results why make it so you cancel your protection and leave your findings free for manipulation and incorrection. An obvious mitake from microsoft in my opinion.

gzazJim
06-26-2001, 05:00 PM
Hey truss2001,

Yeah - that does seem a little silly. I suppose I understand why they did it though (in this one case at least). It would have been more effective to allow password protection rather than just that silly "Protect" trash though :)

Regards, and glad you figured it out!

Jim