设置word当前文档所有图表宽度为14cm并居中
alt+f11,新建模块粘贴进去就能用
Sub ChangeChartWidthto14()
Dim aktDocument As Document
Dim shp As Shape
Dim oInLineSp As InlineShape
Set aktDocument = Word.ActiveDocument
With aktDocument
For Each shp In .Shapes
'判断shape是否是图表
If shp.HasChart Then
'设置宽度14cm
shp.Width = Application.CentimetersToPoints(14)
'居中
shp.Range.ParagraphFormat.Alignment = wdAlignParagraphCenter
End If
Next
For Each oInLineSp In .InlineShapes
'判断inlineshape是否是图表
If oInLineSp.HasChart Then
oInLineSp.Width = Application.CentimetersToPoints(14)
oInLineSp.Range.ParagraphFormat.Alignment = wdAlignParagraphCenter
End If
Next
End With
End Sub