Created
April 13, 2017 06:15
-
-
Save jamesBan/1d8eb50c306b20cb64967f10fe12b6e4 to your computer and use it in GitHub Desktop.
python 调用office 转换文档
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys | |
| import os | |
| import glob | |
| import win32com.client | |
| def convert(files, formatType = 32): | |
| powerpoint = win32com.client.Dispatch("PowerPoint.Application") | |
| powerpoint.Visible = 1 | |
| for filename in files: | |
| newname = os.path.splitext(filename)[0] + ".pdf" | |
| deck = powerpoint.Presentations.Open(filename) | |
| deck.SaveAs(newname, formatType) | |
| deck.Close() | |
| powerpoint.Quit() | |
| files = glob.glob(os.path.join(sys.argv[1],"*.ppt*")) | |
| convert(files) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment