python自动化:批量自动将PPT中的内容复制到word中(附完整源码)

python自动化:批量自动将PPT中的内容复制到word中

下面是一个示例 Python 脚本,可以用来批量将 PPT 中的内容复制到 Word 文档中:

import os
from pptx import Presentation
from docx import Document

def copy_ppt_to_word(ppt_file, word_file):
    """
    将PPT中的内容复制到Word中
    """
    # 创建一个新的Word文档
    doc = Document()

    # 打开PPT文件
    prs = Presentation(ppt_file)

    # 遍历每一页幻灯片
    for slide in prs.slides:
        # 遍历每个形状(包括文本框、图片等)
        for shape in slide.shapes:
            # 如果形状是文本框
            if shape.has_text_frame:
                text_frame = shape.text_frame
                # 遍历文本框中的段落
                for paragraph in text_frame.paragraphs:
                    # 将每个段落的文本添加到Word文档中
                    doc.add_paragraph(paragraph.text)

    # 保存Word文档
    d

你可能感兴趣的:(Python实战教程,python,自动化,powerpoint)