如何在VBA中使用左缩进?

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

这是我正在使用的代码,但不起作用,属性

LeftIndent
不存在于
textRange
对象中。

Sub Puce_2nd_level()
    Dim slide As slide
    Dim shape As shape
    Dim textRange As textRange

    If Not ActiveWindow.Selection.textRange Is Nothing Then
        Set textRange = ActiveWindow.Selection.textRange

          
        With textRange.ParagraphFormat
            .LeftIndent = 3   '<-- This function doesn't exist
            .SpaceAfter = 3
            .Alignment = ppAlignLeft 
        '.FirstLineIndent =
        End With
    Else
        MsgBox "Veuillez sélectionner le texte auquel vous souhaitez ajouter une puce.", vbExclamation
    End If
    
End Sub 
vba powerpoint
1个回答
0
投票

您需要使用属性

TextRange2
而不是
TextRange
,它具有
LeftIndent
-属性:

Sub Puce_2nd_level()
    Dim slide As slide
    Dim shape As shape
    Dim tr2 As TextRange2

    If Not ActiveWindow.Selection.TextRange2 Is Nothing Then
        Set tr2 = ActiveWindow.Selection.TextRange2

        With tr2.ParagraphFormat
            .LeftIndent = 3
            .SpaceAfter = 3
            .Alignment = ppAlignLeft 
        End With
    Else
        MsgBox "Veuillez sélectionner le texte auquel vous souhaitez ajouter une puce.", vbExclamation
    End If

    Set tr2 = Nothing
End Sub 
© www.soinside.com 2019 - 2024. All rights reserved.