Text aus Powerpoint extrahieren

Text aus Powerpoint extrahieren

Also, ich habe dieses nette Skript hier gefunden: http://www.pptfaq.com/FAQ00274_Text_in_eine_Textdatei_exportieren-_Text_aus_PowerPoint_extrahieren_-Mac_oder_PC-.htm (Ich verwende das zweite)

Der Importteil ist dieser:

 For Each oShp In oSld.Shapes                'Loop thru each shape on slide
      'Check to see if shape has a text frame and text
      If oShp.HasTextFrame And oShp.TextFrame.HasText Then
        If oShp.Type = msoPlaceholder Then
            Select Case oShp.PlaceholderFormat.Type
                Case Is = ppPlaceholderTitle, ppPlaceholderCenterTitle
                    Print #iFile, "Title:" & vbTab & oShp.TextFrame.TextRange
                Case Is = ppPlaceholderBody
                    Print #iFile, "Body:" & vbTab & oShp.TextFrame.TextRange
                Case Is = ppPlaceholderSubtitle
                    Print #iFile, "SubTitle:" & vbTab & oShp.TextFrame.TextRange
                Case Else
                    Print #iFile, "Other Placeholder:" & vbTab & oShp.TextFrame.TextRange
            End Select
        Else
            Print #iFile, vbTab & oShp.TextFrame.TextRange
        End If  ' msoPlaceholder
      Else  ' it doesn't have a textframe - it might be a group that contains text so:
        If oShp.Type = msoGroup Then
            sTempString = TextFromGroupShape(oShp)
            If Len(sTempString) > 0 Then
                Print #iFile, sTempString
            End If
        End If
      End If    ' Has text frame/Has text

    Next oShp

Ich habe es bereits ein wenig geändert, sodass die Ausgabedatei weder "Titel", "Anderer Platzhalter" noch dergleichen enthält und auch keine Tabulatoren ("vbTab") einfügt. Allerdings wird jede Zeile (oder jeder Absatz) in der Ausgabedatei in eine neue Zeile eingefügt.

Die Frage:Wie kann ich dem Skript sagen, dass es den gesamten „Inhalt“ einer „Folie“/eines „Textkörpers“ in dieselbe Zeile/Zelle kopieren soll?

Mir ist aufgefallen, dass dieses Skript (und weder dieseshttp://www.pptfaq.com/FAQ00332_Foliennummer_und_Titeltext_in_eine_Textdatei_exportieren.htm) zeigt dieses Verhalten für Titel, nur für „body“ oder „ppPlaceholderBody“.

Ich habe keine Ahnung, warum das so ist oder was der Unterschied ist. Kann es einfach nicht zwischen zwei Zeilen oder Bulletins unterscheiden, selbst wenn diese dieselbe Form/Box haben? Mein Ziel ist eine konsistente Zeilen-/Zellennummerierung über mehrere PPTs hinweg, sodass eine hinzugefügte Zeile in Folie 2 nicht dazu führt, dass der Inhalt von Folie 5 in die nächste Zeile verschoben wird.

Ich danke Ihnen für Ihre Hilfe!

Antwort1

Meine PowerPoint-Installation ist im Moment nicht verfügbar, daher ist dies ungetestet. Aber ...

Sie müssen lediglich eine Zeichenfolgenvariable erstellen und ihr etwas hinzufügen. Wenn Sie dann mit der Folie fertig sind, kopieren Sie diese Zeichenfolge in eine Excel-Zelle.

Dim slideText As String
For Each oShp In oSld.Shapes                 'Loop thru each shape on slide
    If Len(slideText) > 0 Then
        '--- strip the unneeded trailing CRLF
        slideText = Left$(slideText, Len(slideText) - 2)
        '--- now copy the string to the appropriate cell in Excel
    Else
        '--- clear the string for the next slide
        slideText = vbNullString
    End If

    'Check to see if shape has a text frame and text
    If oShp.HasTextFrame Then
        If oShp.TextFrame.HasText Then
            If oShp.Type = msoPlaceholder Then
                Select Case oShp.PlaceholderFormat.Type
                    Case Is = ppPlaceholderTitle, ppPlaceholderCenterTitle
                        slideText = slideText & "Title:" & vbTab & _
                                    oShp.TextFrame.TextRange & vbCrLf
                    Case Is = ppPlaceholderBody
                        slideText = slideText & "Body:" & vbTab & _
                                    oShp.TextFrame.TextRange & vbCrLf
                    Case Is = ppPlaceholderSubtitle
                        slideText = slideText & "SubTitle:" & vbTab & _
                                    oShp.TextFrame.TextRange & vbCrLf
                    Case Else
                        slideText = slideText & "Other Placeholder:" & _
                                    vbTab & oShp.TextFrame.TextRange & vbCrLf
                End Select
            Else
                slideText = slideText & vbTab & oShp.TextFrame.TextRange
            End If                           ' msoPlaceholder
        End If
    Else
        ' it doesn't have a textframe - it might be a group that contains text so:
        If oShp.Type = msoGroup Then
            sTempString = TextFromGroupShape(oShp)
            If Len(sTempString) > 0 Then
                slideText = slideText & sTempString & vbCrLf
            End If
        End If
    End If                                   ' Has text frame/Has text
Next oShp

'--- catch the text on the last slide here
If Len(slideText) > 0 Then
    '--- strip the unneeded trailing CRLF
    slideText = Left$(slideText, Len(slideText) - 2)
    '--- now copy the string to the appropriate cell in Excel
End If

Natürlich führen Sie diese Schleife für jede Folie durch.

Antwort2

Ich glaube nicht, dass das hilft, aber das hier:https://stackoverflow.com/questions/45468824/printing-from-ppt-vba-to-an-excel-spreadsheet versucht etwas Ähnliches mit Lbound und Ubound, um in bestimmte Zellen zu drucken.

Solange die Zellen über mehrere PPT/XLS hinweg konsistent bleiben, weiß ich nicht wirklich, wohin die Zeichenfolgen gehen ...

(Es wählt allerdings auch eine bestimmte XLS-Datei aus, obwohl ich für jeden Ausdruck eine neue erstellen möchte. Das sollte jedoch mit dem Code, den ich bereits habe und der entweder eine bestimmte Datei erstellt oder den Dateinamen aus der PPT verwendet, kein Problem sein.)

verwandte Informationen