excel - 如何通过VBA Excel设置对齐Shape中的段落?

标签 excel vba

Shape 中,我有 2 个段落,其中第 1 段右对齐,第 2 段左对齐:

enter image description here

如果我想使用 VBA for Excel 更改形状内段落的对齐方式,我该怎么做?

最佳答案

我认为这很简单。检查此代码:

Sub AlignParagraphs()

    Dim SHP As Shape
    Set SHP = ActiveSheet.Shapes(1)

    Dim txtRNG2 As TextRange2
    Set txtRNG2 = SHP.TextFrame2.TextRange

    With txtRNG2
        .Paragraphs(1).ParagraphFormat.Alignment = msoAlignRight
        .Paragraphs(2).ParagraphFormat.Alignment = msoAlignLeft
    End With

End Sub

关于excel - 如何通过VBA Excel设置对齐Shape中的段落?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32195243/

相关文章:

vba - excel vba宏中如何循环绘图

excel - 一次将多个单元格引用从相对更改为绝对 ($)

python - 使用 python pandas 将现有的 excel 表 append 到新的数据框

python - 如果没有为 io 传入缓冲区或路径,则必须显式设置引擎

database - 可移动表单上的 MS Access/在它自己的窗口中有一个表单不受应用程序的限制

excel - 如何在 VBA 中定义结构? Delphi "record"命令的替代方案

c# - 是什么导致抛出带有消息 "Cannot access ' System.IO.MemoryStream'"的 COMException?

excel - 搜索和偏移索引后按索引引用字符串字符

vba - 如何选择范围的一部分

vba - 我应该重置 VBA 对象变量还是关闭设置的对象然后设置为新变量?