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

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

相关推荐
骆驼爱记录20 小时前
WPS文档标题一键加形状
自动化·word·excel·wps·新人首发
小真zzz2 天前
ChatPPT Nano Banana Pro · Magic模式深度解析 ——重新定义“所想即所得”的PPT智能编辑
人工智能·ai·powerpoint·ppt·aippt
还不秃顶的计科生2 天前
wps/word单倍行距加入公式空白间隙仍然很大?
word·wps
Archer-3 天前
mathtype的右编号灰色
word
2501_907136824 天前
图片转word文档
word·软件需求
王解4 天前
AI生成PPT的技术演进:从智能填充到认知增强
人工智能·powerpoint
2501_946961475 天前
PPT课件怎么做?2026最新版制作流程与免费资源汇总
powerpoint
github.com/starRTC5 天前
Claude Code中英文系列教程35:通过API使用Skills创建ppt,word文档和pdf
pdf·word·powerpoint·ai编程
琛説7 天前
⚡PitchPPT:将PPT导出为高清全图PPT,并控制PPT文件大小在固定MB/GB以内【解析算法原理 · 作者谈】
windows·python·算法·github·powerpoint
我在这里呀7 天前
免费在线PDF翻译工具(保留排版,可导出Word)
pdf·word