1

次のような階層リストを含む Powerpoint のテキスト ボックスがあります。

* レベル1
  - レベル2
    . レベル3
    . 再びレベル3
  - 再びレベル 2
*再びレベル1

これは、箇条書きリストとしてフォーマットされています。

このテキスト (アジェンダ) に基づいて、次の行をタイトルとして、すべての行のスライドを作成しています。

Set shpSource = ActiveWindow.Selection.ShapeRange
Set pre = ActivePresentation
Set sli = ActiveWindow.Selection.SlideRange(1)

For Each varStr In Split(shpSource.TextFrame2.TextRange, vbCr)            
    Set sli = pre.Slides.AddSlide(sli.SlideIndex + 1, sli.CustomLayout)
    sli.Shapes(2).TextFrame.TextRange = varStr
Next

私の質問は次のとおりです。各弾丸がどのレベルであるかをどのように把握できますか?

各行をタイトルとして書くだけでなく、「レベル 1 > レベル 2 > レベル 3」のようなタイトル、つまりある種のパンくずリストを付けたいと思います。

4

1 に答える 1

2

Okay, found the solution - each Line has .ParagraphFormat.IndentLevel that can be used. Here's the final code to convert a hierarchical list from a selected text box to new slides with breadcrumbs as titles:

Sub ConvertAgenda()
    Dim shpSource As ShapeRange
    Dim pre As Presentation
    Dim sli As Slide
    Dim trng As TextRange2
    Dim strL1 As String, strL2 As String, strFull As String, strCurrent As String

    Set shpSource = ActiveWindow.Selection.ShapeRange
    Set pre = ActivePresentation
    Set sli = ActiveWindow.Selection.SlideRange(1)

    For Each trng In shpSource.TextFrame2.TextRange.Lines
        strCurrent = Left(trng, Len(trng) - 1)
        Select Case trng.ParagraphFormat.IndentLevel
            Case 1:
                strL1 = strCurrent
                strFull = strCurrent
            Case 2:
                strL2 = strCurrent
                strFull = strL1 & " > " & strCurrent
            Case 3:
                strFull = strL1 & " > " & strL2 & " > " & strCurrent
        End Select

        Set sli = pre.Slides.AddSlide(sli.SlideIndex + 1, sli.CustomLayout)
        sli.Shapes(2).TextFrame.TextRange = strFull
    Next
End Sub
于 2013-03-07T09:32:22.713 に答える