PythonTip >> 博文 >> python

Python合并PPT

zihua 2014-01-16 18:01:44 点击: 2579 | 收藏


 

将多个PPT文件合并成一个PPT文件

def joinPPT():
    '''
    http://www.s-anand.net/blog/automating-powerpoint-with-python/
    http://support.microsoft.com/kb/161661 太废了,此法不可取
    '''
    import win32com.client, sys
    Application = win32com.client.Dispatch("PowerPoint.Application")
    Application.Visible = True
    # Create new presentation
    new_ppt = Application.Presentations.Add()
    
    from jhl_utils.file_dir import listFiles
    files = listFiles('E:\\QA1110',patterns = "*.ppt",recurse=0)
    for f in files:
        # 先打开一遍读页数
        exit_ppt = Application.Presentations.Open(f)
        page_num = exit_ppt.Slides.Count
        exit_ppt.Close()
        #http://msdn.microsoft.com/en-us/library/microsoft.office.interop.powerpoint.slides.insertfromfile.aspx
        num = new_ppt.Slides.InsertFromFile(f,new_ppt.Slides.Count,1,page_num)
     
    #for Slide in Presentation.Slides:
         #for Shape in Slide.Shapes:
                 #Shape.TextFrame.TextRange.Font.Name = "Arial"                
    Presentation.Save()
    Application.Quit()

原文链接:http://my.oschina.net/cppblog/blog/34847

作者:zihua | 分类: python | 标签: python | 阅读: 2579 | 发布于: 2014-01-16 18时 |