导出带格式的笔记

Exporting notes with formatting

我有以下 Microsoft Powerpoint 365 宏,用于将笔记导出到单独的 .txt 文件中。问题是它从注释中的注释中排除了要点。我该如何解决这个问题?

Sub ExportNotesText()

    Dim oSlides As Slides
    Dim oSl As Slide
    Dim oSh As Shape
    Dim strNotesText As String
    Dim strFileName As String
    Dim intFileNum As Integer
    Dim lngReturn As Long

    ' Get a filename to store the collected text
    strFileName = InputBox("Enter the full path and name of file to extract notes text to", "Output file?", ActivePresentation.Path + "\notes.txt")

    ' did user cancel?
    If strFileName = "" Then
        Exit Sub
    End If

    ' is the path valid?  crude but effective test:  try to create the file.
    intFileNum = FreeFile()
    On Error Resume Next
    Open strFileName For Output As intFileNum
    If Err.Number <> 0 Then     ' we have a problem
        MsgBox "Couldn't create the file: " & strFileName & vbCrLf _
            & "Please try again."
        Exit Sub
    End If
    Close #intFileNum  ' temporarily

    ' Get the notes text
    Set oSlides = ActivePresentation.Slides
    For Each oSl In oSlides
        For Each oSh In oSl.NotesPage.Shapes
        If oSh.PlaceholderFormat.Type = ppPlaceholderBody Then
            If oSh.HasTextFrame Then
                If oSh.TextFrame.HasText Then
                    strNotesText = strNotesText & "Slide: " & CStr(oSl.SlideIndex) & vbCrLf _
                    & oSh.TextFrame.TextRange.Text & vbCrLf & vbCrLf
                End If
            End If
        End If
        Next oSh
    Next oSl

    ' now write the text to file
    Open strFileName For Output As intFileNum
    Print #intFileNum, strNotesText
    Close #intFileNum

    ' show what we've done
    ' lngReturn = Shell("NOTEPAD.EXE " & strFileName, vbNormalFocus)

End Sub

获得对注释 TextFrame 的引用后,您可以循环遍历其 .TextRange.Paragraphs 集合。

这会给你一个星号 & space & 和段落的文本,如果没有项目符号,则只是文本:

If .Paragraphs(x).ParagraphFormat.Bullet.Type = ppBulletUnnumbered Then
   Debug.Print "* " & .Paragraphs(x).Text
Else
   Debug.Print .Paragraphs(x).Text
End if

可能还有编号或图片项目符号。咱不去了