删除双空格而不删除子弹级别

时间:2016-11-20 15:46:51

标签: vba

每当我在powerpoint中运行代码时,它会删除textranges,textframes中的所有项目符号,但我想保留所有项目符号,如果有人知道的话请提供建议

Sub removeSpaces()
Dim shpText As String

For Each sld In ActivePresentation.Slides
    For Each shp In sld.Shapes
        If shp.HasTextFrame Then
            shpText = shp.TextFrame.TextRange.Text 'Get the shape's text
            Do While InStr(shpText, "  ") > 0
                shpText = Trim(Replace(shpText, "  ", " "))
            Loop
        shp.TextFrame.TextRange.Text = shpText 'Put the new text in the shape

        Else
            shpText = vbNullString
        End If
    Next shp
Next sld
End Sub

1 个答案:

答案 0 :(得分:0)

删除修剪并尝试。

Do While InStr(shpText, "  ") > 0
   shpText = Replace(shpText, "  ", " ")
Loop
相关问题