动态调整绘图区域大小以查看簇状条形图类别轴中的截断文本
Resize Plot Area dynamically to see truncated text in Category Axis of a Clustered Bar Chart
我正在将 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
我正在将 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