파워포인트에서 텍스트 추출

파워포인트에서 텍스트 추출

그래서 저는 여기에서 다음과 같은 멋진 스크립트를 찾았습니다. http://www.pptfaq.com/FAQ00274_Export_Text_to_a_text_file-_extract_text_from_PowerPoint_-Mac_or_PC-.htm (저는 두 번째 것을 사용하고 있습니다)

가져오기 부분은 다음과 같습니다.

 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

이미 약간 수정했으므로 출력 파일에는 "제목", "기타 자리 표시자" 및 해당 텍스트가 포함되지 않으며 탭("vbTab")도 삽입되지 않습니다. 그러나 각 줄(또는 단락)을 outfile의 새 줄에 넣습니다.

질문:'슬라이드'/'본문'의 모든 '콘텐츠'를 동일한 줄/셀에 덤프하도록 스크립트에 어떻게 지시할 수 있습니까?

나는 이 스크립트가 (이것도 아니고http://www.pptfaq.com/FAQ00332_Export_Slide_Number_and_Title_Text_to_a_text_file.htm)는 "body" 또는 "ppPlaceholderBody"에 대해서만 제목에 대해 이 동작을 나타냅니다.

왜 그런지, 차이점이 무엇인지 전혀 모르겠습니다. 동일한 모양/상자에서도 두 줄이나 게시판의 차이점을 단순히 구분할 수 없습니까? 내 목표는 여러 .ppt에 대해 일관된 줄/셀 번호를 지정하여 슬라이드 2에 한 줄을 추가해도 슬라이드 5의 내용이 다음 줄로 이동되지 않도록 하는 것입니다.

도와주셔서 감사합니다!

답변1

현재 내 PowerPoint 설치가 중단되었으므로 테스트되지 않았습니다. 하지만...

문자열 변수를 만들어 추가한 다음 슬라이드가 끝나면 해당 문자열을 Excel 셀에 복사하면 됩니다.

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

물론 각 슬라이드에 대해 이 루프를 수행하고 있습니다.

답변2

나는 이것이 도움이 될 것이라고 생각하지 않습니다. 그러나 이것은 다음과 같습니다.https://stackoverflow.com/questions/45468824/printing-from-ppt-vba-to-an-excel-spreadsheet 특정 셀에 인쇄하기 위해 Lbound 및 Ubound를 사용하여 비슷한 것을 시도합니다.

여러 ppt/xls에서 셀이 일관성을 유지하는 한 문자열이 어디로 가는지는 알 수 없습니다.

(특정 xls 파일도 선택하지만 인쇄할 때마다 새 파일을 만들고 싶지만 지정된 파일을 생성하거나 ppt의 파일 이름을 사용하는 이미 가지고 있는 코드에는 문제가 되지 않습니다. )

관련 정보