VBA Word中的图形图表对齐

问题描述 投票:1回答:1

我在Microsoft Word文档中有一些图表对象,我想使用VBA代码将其与中心对齐。什么是书面缺点似乎工作正常,因为它正确检测图形图表,但后来我不知道如何居中。

Sub CenterChart()
Dim n As Integer, i As Integer
Dim graf As Object
n = Application.ActiveDocument.InlineShapes.Count
If n <> 0 Then
    For i = 1 To n
        Set graf = Application.ActiveDocument.InlineShapes(i)
        If graf.HasChart Then
            'Here the code to align to center 
        Else
        End If
    Next i
End If
End Sub
vba ms-word word-vba
1个回答
0
投票

由于您使用的是InlineShapes格式化命令与文本相同 - 您使用居中的段落对齐方式。例如

    If graf.HasChart Then
        graf.Range.ParagraphFormat.Alignment = wdAlignParagraphCenter
    Else
    End If
© www.soinside.com 2019 - 2024. All rights reserved.