Forum Discussion
perkin_warbeck
May 31, 2023Brass Contributor
How do I rotate a 3D chart in VBA?
I am trying to rotate a surface chart in a certain way, but the assignments to RotationY and RotationX have no effect. I have tried positioning the two assignments after the End With statement, but again, they have no effect. What am I doing wrong?
Dim myChart As Shape
Set myChart = ActiveSheet.Shapes.AddChart2
'
' Make it big
'
myChart.Height = 648 ' 9 inches
myChart.Width = 648
'
' Position the upper left-hand corner of the chart at position 'pos'
'
myChart.Top = pos.Top
myChart.Left = pos.Left
'
' Orient the chart the way the paper is oriented when measuring it
' TBD This is not working. The values have no effect
'
myChart.ThreeD.RotationY = -180
myChart.ThreeD.RotationX = -90
'
Dim min As Integer
Dim max As Integer
min = Range("min").Value
max = Range("max").Value
'
With myChart.Chart
.SetSourceData rng
.ChartType = xlSurfaceTopView
.ChartTitle.Text = "L values"
.HasLegend = True
.Axes(xlValue).MinimumScale = min
.Axes(xlValue).MaximumScale = max
.Axes(xlValue).MajorUnit = (max - min) / 5
.Axes(xlSeries).TickLabelSpacing = 1
.Axes(xlSeries).TickLabelPosition = xlHigh
.Axes(xlCategory).TickLabelPosition = xlHigh
.Axes(xlCategory).ReversePlotOrder = True
.SetElement (msoElementPrimaryCategoryGridLinesMajor)
.SetElement (msoElementSeriesAxisGridLinesMajor)
End With
No RepliesBe the first to reply