Use Python to do PPT services for importing pictures

Source: Internet
Author: User

Project needs to do WinForm program and PowerPoint interaction, the WinForm generated images are automatically copied to the PPT. A simple service solution is currently being done using Python. Because the requirements are 32-bit programs, the following are all 32-bit versions.

The first step is to install python2.7 32-bit.

Second, install Py2exe 32-bit.

Step three, install Pywin32 32-bit.

Fourth step, write the code with Eclipse (Pydev plugin), see the attachment. The main contents are as follows:

wavy_ppt_service.py

Import socketserverimport win32com.clientimport sysclass mytcphandler ( Socketserver.baserequesthandler):     "" "    the requesthandler  class for our server.    It is instantiated once  Per connection to the server, and must    override the  handle ()  method to implement communication to the     client.     "" "    def handle (self):         # self.request is the tcp socket connected to the  CLIENT        SELF.DATA = SELF.REQUEST.RECV (1024). Strip () #        print  "{} wrote:". Format (self.client_address [0]) #      &Nbsp; print self.data        # just send back  the same data, but upper-cased#         Self.request.sendall (Self.data.upper ())                  application = win32com.client.dispatch ("PowerPoint.Application")          currentSlide = Application.ActiveWindow.View.Slide         currentslide.shapes.paste () host, port =  "localhost",  int (sys.argv[1]) #HOST, port =  "localhost",  9999# create the server,  binding to localhost on port 9999server = socketserver.tcpserver (( Host, port),  mytcphandler) # activate the server; this will keep  running until you#&Nbsp;interrupt the program with ctrl-cserver.serve_forever () 

It is a service that is done by the client and the server, and the server receives the data and copies the Clipboard pictures to the PPT.

Open cmd, call Buildexe32.bat can generate dist directory, contains the EXE program.

This article is from the "some" blog, be sure to keep this source http://2924037.blog.51cto.com/2914037/1692967

Use Python to do PPT services for importing pictures

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.