import win32com.client, sys
from glob import glob
def join_ppt(ppt_folder):
Application = win32com.client.Dispatch("PowerPoint.Application")
Application.Visible = True
# Create new presentation
new_ppt = Application.Presentations.Add()
files = glob(ppt_folder)
for f in files:
# Open and read page numbers
exit_ppt = Application.Presentations.Open(f)
page_num = exit_ppt.Slides.Count
exit_ppt.Close()
num = new_ppt.Slides.InsertFromFile(f,new_ppt.Slides.Count,1,page_num)
Presentation.Save()
Application.Quit()
if __name__ == '__main__':
join_ppt(sys.argv[1])
使用方法,如果将代码保存为join_ppt.py,在当前文件夹下有ppt文件夹,ppt文件夹下有若干文件夹,每个文件夹下都有若干PPT:python join_ppt.py a/*/*.ppt
即可。
参考文献:http://my.oschina.net/cppblog/blog/34847