Posts Tagged automation

Use python to create PowerPoint slides automatically

I have a large number of images. I want to organize them in powerpoint files by automatically insert each picture to a new powerpoint slide and control it’s position and size. I came across a nice Python library – python-pptx at It provides functions to automate generating PowerPoint slides. Below are some information from the website. I keep the information for future use.

python-pptx is a Python library for creating and updating PowerPoint (.pptx) files.

A typical use would be generating a customized PowerPoint presentation from database content, downloadable by clicking a link in a web application. Several developers have used it to automate production of presentation-ready engineering status reports based on information held in their work management system. It could also be used for making bulk updates to a library of presentations or simply to automate the production of a slide or two that would be tedious to get right by hand.

Chris Moffitt wrote a nice article to explain how to use the above library at He specifically talked about how to use PowerPoint templates to generate new slides.



Tags: , , , ,

TwitterGIFT project – Automation of following friends on Twitter

What is TwitterGIFT project?

GIFT is an acronym of Get Innumerable Followers on Twitter. TwitterGIFT project was started shortly after we registered an account (usbargains) for our business on Twitter. Original GIFT application was a set of PERL scripts running on one of our servers. All proven successful Twitter strategies and tips were incorporated into the system. This account now has many many followers just after several MONTHS it was created. Thanks for the TwitterGIFT project that boosts our Twitter account and dramatically changes our vision to connect people. Our web traffic grows exponentially.

Main Features

TwitterGIFT automates the following Twitter activities:

  • Follow friends you do not follow now to establish a solid relationship
  • Build target friend pool in which you have never followed
  • Follow new friends selected from the target friend pool
  • Send direct messages (DM) to new followers to show your care and kindness
  • Remove current non-followers to give your more room to follow new friends

We know there are thousands of small businesses are still struggling to be success on Twitter. It is our pleasure to announce that we are going to share our successful experience on Twitter with you. TwitterGIFT is completely rewriting in Windows environment. It has a friendly Windows user interface. The beta version of the TwitterGIFT application is released.

Important notice

TwitterGIFT is freeware. We keep the copyright. You can download, copy, use it free of charge. Use it at your own risk. We are not responsible for any damages at any circumstances. One important thing to remember is “DO not use one than once a day. Otherwise, your Twitter account could be suspended!”.

Get the beta version

Click link here to download the beta version of TwitterGIFT – After you download it, just copy the zip file to a folder and unzip all files. Then double click TwitterGIFT.exe file to start the program. This is green software you do not need to install it.

Feedback and bug report

Because TwitterGIFT is still under intensive development, please send us your feedback about new ideas, bugs, errors, and whatever related to this application. All comments are welcome.


Tags: , , , , , , , , , , ,

Automate PowerPoint Slide Creation

One time I have to generate a lot of graphs on fly and insert them to PowerPoint slides to create a nice presentation. The situation is that I have to repeat this process again and again every week or days. The graphs generated on fly are a fixed set. Nobody want to do this boring work again and again. So I developed a VBA script in PowerPoint. I can use it to automate the process. Here are some pieces that are relevant to the auntomatic process.
First of all, we need insert new slide.

' create a new blank slide
ActiveWindow.View.GotoSlide Index:=ActivePresentation.Slides.Add(Index:=1, Layout:=ppLayoutTitle).SlideIndex
ActiveWindow.Selection.SlideRange.Layout = ppLayoutBlank 

Second, we insert pictures to each slide and put them in fixed position precisely.

ActiveWindow.Selection.SlideRange.Shapes.AddPicture(FileName:="picture1.jpg", LinkToFile:=msoFalse, SaveWithDocument:=msoTrue, left:=12, top:=12, Width:=770, Height:=690).Select
' set size of picture
With ActiveWindow.Selection.ShapeRange
.Fill.Transparency = 0#
.Height = 262.38
.Width = 293#
.left = 100#
.top = 50#
End With 

Third, you may need insert textboxes to the slide. Here is sample code.

ActiveWindow.Selection.SlideRange.Shapes.AddTextbox(msoTextOrientationVerticalFarEast, 29.875, 84, 36.125, 348).Select
ActiveWindow.Selection.ShapeRange.TextFrame.WordWrap = msoTrue
With ActiveWindow.Selection.TextRange.ParagraphFormat
.LineRuleWithin = msoTrue
.SpaceWithin = 1
.LineRuleBefore = msoTrue
.SpaceBefore = 0.5
.LineRuleAfter = msoTrue
.SpaceAfter = 0
End With
ActiveWindow.Selection.ShapeRange.ScaleHeight 0.93, msoFalse, msoScaleFromBottomRight
ActiveWindow.Selection.TextRange.ParagraphFormat.Alignment = ppAlignCenter
ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Characters(Start:=1, Length:=0).Select
With ActiveWindow.Selection.TextRange
.Text = "Sample graphes"
With .Font
.NameAscii = "Arial"
.Size = 18
.Bold = msoFalse
.Italic = msoFalse
.Underline = msoFalse
.Shadow = msoFalse
.Emboss = msoFalse
.BaselineOffset = 0
.AutoRotateNumbers = msoFalse
.Color.SchemeColor = ppForeground
End With
End With
ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Font.Bold = msoTrue

If you need move to slide to slide, the following code can do that.

ActiveWindow.View.GotoSlide (i) 

In the second step, when we position graphs, we need pixel units instead of inches PowerPoint uses. To convert inches in PowerPoint slide to pixels, the following formula can be used:

number in inches / 2.54 * 72 

By using this formula, you can precisely position your graphs to slides.


Tags: , , ,