一键导出PPT备注到Word

步骤1:

alt+F11进入如下界面:

步骤2:

插入--->模块弹出:

步骤3:

将下面代码复制进去,然后将文件保存到本地,方便以后随时加载。

复制代码
Sub ExportNotesToWord()
    Dim pptSlide As Slide
    Dim pptNotes As String
    Dim i As Integer
    Dim WordApp As Object
    Dim WordDoc As Object
    Dim FilePath As String
    Dim presPath As String
    Dim presName As String
    Dim dotPos As Long
    Dim baseName As String

    ' 先确保PPT已保存,才能拿到路径
    presPath = ActivePresentation.Path
    If presPath = "" Then
        MsgBox "当前PPT尚未保存到磁盘,请先保存PPT,再导出备注。"
        Exit Sub
    End If

    ' 用PPT文件名生成"讲稿.docx"
    presName = ActivePresentation.Name
    dotPos = InStrRev(presName, ".")
    If dotPos > 0 Then
        baseName = Left(presName, dotPos - 1)
    Else
        baseName = presName
    End If
    FilePath = presPath & "\" & baseName & "讲稿.docx"

    ' 启动Word
    On Error Resume Next
    Set WordApp = CreateObject("Word.Application")
    On Error GoTo 0
    If WordApp Is Nothing Then
        MsgBox "无法启动 Word 应用程序,请确保已安装 Microsoft Word。"
        Exit Sub
    End If

    Set WordDoc = WordApp.Documents.Add
    ' WordApp.Visible = True '需要调试可打开

    ' 遍历幻灯片
    i = 0
    For Each pptSlide In ActivePresentation.Slides
        i = i + 1

        pptNotes = ""
        On Error Resume Next
        pptNotes = pptSlide.NotesPage.Shapes.Placeholders(2).TextFrame.TextRange.Text
        On Error GoTo 0

        Dim startPos As Long, endPos As Long
        Dim headText As String, fullText As String
        Dim rng As Object

        headText = "Page " & i & ": "              ' 需要加粗的部分
        fullText = headText & pptNotes & vbCrLf & vbCrLf

        ' 记录插入前的末尾位置(Word 的 Range.Start 是字符位置)
        startPos = WordDoc.Content.End - 1  ' -1 避免落在文档末尾标记之后

        ' 插入文本
        WordDoc.Content.InsertAfter fullText

        ' 计算加粗区间:从 startPos 开始,长度为 headText
        endPos = startPos + Len(headText)

        Set rng = WordDoc.Range(startPos, endPos)
        rng.Font.Bold = True
    Next pptSlide

    ' 统一Word格式:宋体、小四、1.2倍行距
    With WordDoc.Content.Font
        .Name = "宋体"
        .Size = 12  ' 小四
    End With

    ' 保存并退出
    WordDoc.SaveAs FilePath
    WordDoc.Close
    WordApp.Quit

    Set WordDoc = Nothing
    Set WordApp = Nothing

    MsgBox "备注已导出到:" & FilePath
End Sub

导出 到本地,后期需要导出备注时,就需要点击导入,然后加载这个代码。

相关推荐
SpaceAIGlobal12 天前
AI 生成 PPT 工具深度评测与选型指南
人工智能·powerpoint
一头爱吃肉的牛13 天前
2026年10款AI PPT工具横向评测:内容准确性、生成速度、模板丰富度对比
人工智能·powerpoint
qq_5469372713 天前
Excel批量转PDF_Word_图片,支持自动合并报表,效率翻倍。
pdf·word·excel
(Charon)13 天前
【C++ 面试高频:内存管理、RAII 和智能指针详解】
java·开发语言·word
江畔柳前堤13 天前
github实战指南03-Pull Request 全流程实战
开发语言·人工智能·python·深度学习·github·word
取个鸣字真的难14 天前
Image2 生成 PPT 的最后分水岭:Prompt
人工智能·prompt·powerpoint
2603_9541383914 天前
PDF 转 Word 工具深度评测:从参数解析到实战避坑
pdf·word
知南x14 天前
【DPDK例程学习】(4) l2fwd
学习·word
m0_5474866614 天前
《数字图像处理:使用MATLAB分析与实现》全套课件PPT
开发语言·matlab·powerpoint
ShyanZh15 天前
【skill】HTML-PPT:36主题31布局的专业HTML演示文稿工作室
ai·html·powerpoint·html-ppt