Python outputs all text information in the PowerPoint file,
This example describes how to output all text information in a Python PowerPoint file. 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.