一键导出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

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

相关推荐
weixin_416660072 小时前
怎么把 AI Markdown 转为 Word (.docx) 文档?
word·流程图
深念Y10 小时前
AI时代办公格式的演进:PPT与Word的替代已现,Excel将走向何方?
数据库·人工智能·html·word·powerpoint·excel·markdown
家有娇妻张兔兔12 小时前
Apache POI 导出 Word 踩坑实录:Word 分栏为什么做不好左右平铺
c#·word·apache·poi·分栏
无巧不成书02181 天前
2026年AI PPT全流程最优落地方案
人工智能·powerpoint
努力成为大牛吧1 天前
Word/WPS 论文参考文献排版及交叉引用注意事项
word·wps
qq_283720051 天前
Python3 模块精讲|python-docx 万字实战:全自动读写 Word 文档,办公效率直接翻倍
python·自动化·word
gc_22991 天前
学习C#调用OpenXml操作word文档的基本用法(26:学习文本运行类)
word·openxml·run
开开心心就好2 天前
避免借电脑尴尬的故障模拟工具
科技·游戏·visualstudio·edge·pdf·电脑·powerpoint
蒋胜山2 天前
Word 练习题(3)
word
小矮强3 天前
Word总页码减去首页
word