python添加win32com包,将ppt转换为图片

导出excel所需操作
pip install xlwt 安装xlwt-1.2.0-py2.py3-none-any.whl


添加win32模块
cmd 命令下执行python3 registry.py
然后运行pywin32-218.win-amd64-py3.3.exe

 

 

 

下载链接:https://jaist.dl.sourceforge.net/project/pywin32/pywin32/Build%20218/pywin32-218.win-amd64-py3.3.exe


1、MSO.py
        1)、开始-运行-cmd    
        2)、进入win32com\client
            >cd D:\Program Files (x86)\Python33\Lib\site-packages\win32com\client
        3)、执行makepy.py
            D:\Program Files (x86)\Python33\Lib\site-packages\win32com\client>makepy.py
        4)、在弹出窗口中选择"Microsoft Office 15.0 Object Library",确定:
                Generating to D:\Program Files (x86)\Python33\Lib\site-packages\win32com\gen_py\91493440-5A91-11CF-8700-00AA0060263Bx0x2x9.py
                Building definitions from type library...
                Generating...
                Importing module
        5)、从命令行窗口中可以看到在文件夹gen_py中生成了一个.py文件,重命名为:MSO.py


2、MSPPT.py
        重复上述步骤,
        在第4步中选择“Microsoft PowerPoint 15.0 Object Library”,

 

        重命名为:MSPPT.py

 

 

使用时进行导入

import win32com.gen_py.MSO as MSO 
import win32com.gen_py.MSPPT as MSPPT 

g = globals()
for c in dir(MSO.constants): g[c] = getattr(MSO.constants, c) 
for c in dir(MSPPT.constants): g[c] = getattr(MSPPT.constants, c)

def ppt2jpg(path,dPath):
    pythoncom.CoInitialize()
    App = win32com.client.DispatchEx("PowerPoint.Application")
    App.Visible = True
    App.DisplayAlerts= False
    Presentation = App.Presentations.Open(path)
    Presentation.SaveAs(dPath,ppSaveAsJPG)
    Presentation.Close()
    App.Quit()

 

path指ppt文件,dPath指图片保存位置

Member nameDescription
ppSaveAsPresentationSave as a presentation.
ppSaveAsPowerPoint7Reserved for internal use.
ppSaveAsPowerPoint4Reserved for internal use.
ppSaveAsPowerPoint3Reserved for internal use.
ppSaveAsTemplateSave as a template.
ppSaveAsRTFSave as an RTF.
ppSaveAsShowSave as a slide show.
ppSaveAsAddInSave as an AddIn.
ppSaveAsPowerPoint4FarEastReserved for internal use.
ppSaveAsDefaultSave in the default format.
ppSaveAsHTMLSave as an HTML document.
ppSaveAsHTMLv3Save as HTMLv3.
ppSaveAsHTMLDualSave as HTML Dual version.
ppSaveAsMetaFileSave as a MetaFile.
ppSaveAsGIFSave as a GIF image.
ppSaveAsJPGSave as a JPG image.
ppSaveAsPNGSave as a PNG image.
ppSaveAsBMPSave as an BMP image.
ppSaveAsWebArchiveSave as a Web archive.
ppSaveAsTIFSave as a TIF file.
ppSaveAsPresForReviewReserved for internal use.
ppSaveAsEMFSave in the Enhanced MetaFile (EMF) format.
ppSaveAsOpenXMLPresentationSave as an open XML presentation.
ppSaveAsOpenXMLPresentationMacroEnabledSave as a macro-enabled open XML presentation.
ppSaveAsOpenXMLTemplateSave as an open XML template.
ppSaveAsOpenXMLTemplateMacroEnabledSave as a macro-enabled open XML template.
ppSaveAsOpenXMLShowSave as an open XML show.
ppSaveAsOpenXMLShowMacroEnabledSave as a macro-enabled open XML show.
ppSaveAsOpenXMLAddinSave as an open XML add-in.
ppSaveAsOpenXMLThemeSave as an open XML theme.
ppSaveAsPDFSave as a PDF.
ppSaveAsXPSSave in the XML Paper Specification (XPS) format.
ppSaveAsXMLPresentationSave as an XML presentation.
ppSaveAsOpenDocumentPresentationSave as an open document presentation.
ppSaveAsOpenXMLPicturePresentationSave slideshow as an OpenXML Picture Presentation.
ppSaveAsWMVSave slideshow as a Windows Media Video (WMV) file.
ppSaveAsExternalConverterSave as External Converter.
  • 3
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值