我正在将Clustered Bar charts
中的Workbook
复制并粘贴到动态创建的Powerpoint deck
中。条形图的“类别轴”可能有长文本(“轴”标签),有时会被截断。类别轴的Wrap text
选项为greyed out
。所以我想移动Plot Area of the Chart to the Right dynamically
以使类别轴截断的文本可见。
Sub ExportClusteredBarChartsToPowerpoint()
Dim oPPT As Object: Set oPPT = CreateObject("PowerPoint.Application")
With oPPT
.Visible = True
.Activate
End With
Dim oPres As Object: Set oPres = oPPT.presentations.Add
Dim oSlide As Object
Dim iNdx As Integer
Dim oChart As ChartObject
Dim oWS As Worksheet: Set oWS = ThisWorkbook.Sheets("ChartsSheet")
iNdx = 1
With oWS
For Each oChart In oWS.ChartObjects
oChart.Chart.ChartArea.Copy
Set oSlide = oPres.slides.Add(iNdx, 12) 'ppLayoutBlank
oSlide.Shapes.PasteSpecial 0, msoFalse '0=ppPasteDefault
Application.CutCopyMode = False
With oSlide.Shapes(1)
.ScaleWidth 1.75, 0, 1 'msoTrue, msoScaleFromMiddle
.ScaleHeight 1.75, 0, 1 'msoTrue,msoScaleFromMiddle
oPPT.Windows(1).View.ZoomToFit = False
oPPT.Windows(1).View.Zoom = 98
End With
iNdx = iNdx + 1
Next oChart
End With
End Sub
这是否可能,或者是否有使用VBA的替代解决方案?
每次运行都会将左轴区域扩大50点:
With oSlide.Shapes(1)
If .HasChart Then
With .Chart.PlotArea
.Width = .Width - 50
.Left = .Left + 50
End With
End If
End With