Pie Charts

M

Martha D.

I am building a pie chart via code. As soon as I apply data labels, the plot
area resizes to accomodate the labels. Can I prevent this?

I've tried using the plotarea.height/width, etc. properties, but it doesn't
seem to help.

I have turned off font autoscaling. Is there a similar property for the
plot area?
 
A

Andy Pope

Hi,

Does this macro help?

Sub PieLabels()

Dim sngLeft As Single
Dim sngTop As Single
Dim sngWidth As Single
Dim sngHeight As Single

With ActiveSheet.ChartObjects(1).Chart
With .PlotArea
sngLeft = .Left
sngTop = .Top
sngWidth = .Width
sngHeight = .Height
End With

.SeriesCollection(1).ApplyDataLabels AutoText:=True,
LegendKey:=False, _
HasLeaderLines:=True,
ShowSeriesName:=False, _
ShowCategoryName:=True,
ShowValue:=False, _
ShowPercentage:=False,
ShowBubbleSize:=False

With .PlotArea
.Left = sngLeft
.Top = sngTop
.Width = sngWidth
.Height = sngHeight
End With
End With

End Sub

Cheers
Andy
 
M

Martha D.

Actually, after re-booting my PC and re-running the code I already had, it
seemed to work. While I had been able to effect the left and top
positioning, the height and width commands seemed to be ignored. The re-boot
cured it - at least until I try it again today.

I did re-arrange the order of things so that I re-size the chart first, and
then apply the data labels.

Thanks.
 

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