How to output all text information in a PowerPoint file using Python-Python tutorial

Source: Internet
Author: User
This article mainly introduces how to output all the text information in a Python PowerPoint file. it involves the skills related to Python using the com component in windows to operate ppt, which is of great practical value, for more information about how to output all the text in a Python PowerPoint file, see the example below. Share it with you for your reference. The specific analysis is as follows:

The following code depends on windows com, so you must install PowerPoint on the machine to use it. it is very practical to output all plain text information in the pptfile to the specified file.

Import win32comfrom win32com. client import Dispatch, constantsppt = win32com. client. dispatch ('powerpoint. application ') ppt. visible = 1 pptSel = ppt. presentations. open ("c: \ 1.ppt") win32com. client. gencache. ensureDispatch ('powerpoint. application ') f = file ("c: \ 1.txt"," w ") slide_count = pptSel. slides. countfor I in range (1, slide_count + 1): shape_count = pptSel. slides (I ). shapes. count print shape_count for j in range (1, shape_count + 1): if pptSel. slides (I ). shapes (j ). hasTextFrame: s = pptSel. slides (I ). shapes (j ). textFrame. textRange. text f. write (s. encode ('utf-8') + "\ n") f. close () ppt. quit ()

I hope this article will help you with Python programming.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.