【问题标题】:VBA powerpoint Strikethrough of a single wordVBA powerpoint 一个单词的删除线
【发布时间】:2017-12-06 09:15:22
【问题描述】:

我有一个包含几张纸的 powerpoint 文件。在这张纸上是带有文本的文本字段。有些词是删除线。我想列出一个包含删除线的单词的所有幻灯片。 我尝试使用该功能: 如果 objShape.TextFrame2.TextRange.Font.Strikethrough = True 那么

问题是只有在第一个单词被删除时才成立。所以 你好,该功能有效。 你好jaja 功能不起作用 有人对此有解决方案吗?

【问题讨论】:

  • 抱歉,删除线在此编辑器中不起作用。
  • Hallo jaja :该功能有效(现在 Hallo 已完成)。你好jaja : 功能不起作用(现在jaja 被罢工了)

标签: vba powerpoint strikethrough


【解决方案1】:

尝试使用.TextRange2 而不是.TextRange 使用字体。删除线

例子:

Sub ST() 
    With ActiveWindow.Selection 
        .TextRange2.Font.Strikethrough = msoTrue 
        .TextRange2.Font.Fill.ForeColor.RGB = vbRed 
    End With 
End Sub 

以下是两种属性类型处理差异的(不完整)列表:

| TextRange Property    | TextRange Return Type | TextRange2 Property                        | TextRange2 Return Type |
|-----------------------|-----------------------|--------------------------------------------|------------------------|
| ActionSettings        | ActionSettings        | -                                         | -                     |
| Application           | Application           | Application                                | Application            |
| BoundHeight           | Single                | BoundHeight                                | Single                 |
| BoundLeft             | Single                | BoundLeft                                  | Single                 |
| BoundTop              | Single                | BoundTop                                   | Single                 |
| BoundWidth            | Single                | BoundWidth                                 | Single                 |
| (Characters method)   | (TextRange)           | Characters                                 | TextRange2             |
| Count                 | Long                  | Count                                      | Long                   |
| -                    | -                    | Creator                                    | Long                   |
| Font                  | Font                  | Font                                       | Font2                  |
| IndentLevel           | Long                  | (Paragraph Format2 .IndentLevel propety)   | (Long)                |
| LanguageID            | Mso LanguageID        | LanguageID                                 | Mso LanguageID         |
| Length                | Long                  | Length                                     | Long                   |
| (Lines method)        | (TextRange)           | Lines                                      | TextRange2             |
| -                    | -                    | MathZones                                  | TextRange2             |
| Paragraph Format      | Paragraph Format      | Paragraph Format                           | Paragraph Format2      |
| (Paragraphs method)   | (TextRange)           | Paragraphs                                 | TextRange2             |
| Parent                | Object                | Parent                                     | Object                 |
| (Runs method)         | (TextRange)           | Runs                                       | TextRange2             |
| (Sentences method)    | (TextRange)           | Sentences                                  | TextRange2             |
| Start                 | Long                  | Start                                      | Long                   |
| Text                  | String                | Text                                       | String                 |
| (Words method)        | (TextRange)           | Words                                      | TextRange2             |
|                       |                       |                                            |                        |

更多信息:

【讨论】:

    【解决方案2】:

    由于文本框中只有部分文本可能带有下划线,因此您需要查看每个具有文本的形状的 .Runs 集合,以便仅提取被删除的文本。这是一个开始:

    Sub ListStrikeThroughText()
    ' This will list the struck-through text from Slide 1
    ' Adapt as needed to collect all of the text from all slides
    
    Dim sTextList As String
    Dim oShp As Shape
    Dim oRng As TextRange2
    Dim x As Long
    
    With ActivePresentation.Slides(1)
        For Each oShp In .Shapes
            If oShp.HasTextFrame And oShp.TextFrame2.HasText Then
                With oShp.TextFrame2.TextRange
                    For x = 1 To .Runs.Count
                        If .Runs(x).Font.Strikethrough Then
                            sTextList = sTextList & .Runs(x).Text & vbCrLf
                        End If
                    Next
                End With
    
            End If
        Next
    End With
    
    MsgBox sTextList
    
    End Sub
    

    【讨论】:

      猜你喜欢
      • 2014-08-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-31
      • 2021-06-05
      • 1970-01-01
      • 1970-01-01
      • 2017-06-01
      相关资源
      最近更新 更多