【问题标题】:Graphic chart alignment in VBA WordVBA Word中的图形图表对齐
【发布时间】:2020-06-29 15:21:33
【问题描述】:

我在 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


    【解决方案1】:

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

        If graf.HasChart Then
            graf.Range.ParagraphFormat.Alignment = wdAlignParagraphCenter
        Else
        End If
    

    【讨论】:

      猜你喜欢
      • 2020-02-04
      • 1970-01-01
      • 2021-05-30
      • 2021-09-05
      • 2017-12-12
      • 2013-11-04
      • 1970-01-01
      • 2022-01-15
      • 1970-01-01
      相关资源
      最近更新 更多