<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>vba on S Anand</title>
    <link>https://www.s-anand.net/blog/tag/vba/</link>
    <description>Recent content in vba on S Anand</description>
    <generator>Hugo -- 0.164.0</generator>
    <language>en-us</language>
    <lastBuildDate>Wed, 02 Feb 2022 07:44:12 +0000</lastBuildDate>
    <atom:link href="https://www.s-anand.net/blog/tag/vba/index.xml" rel="self" type="application/rss+xml" />
    <item>
      <title>Geocoding in Excel</title>
      <link>https://www.s-anand.net/blog/geocoding-in-excel/</link>
      <pubDate>Wed, 08 May 2013 09:17:03 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/geocoding-in-excel/</guid>
      <description>&lt;p&gt;It’s easy to convert addresses into latitudes and longitudes into addresses in Excel. Here&amp;rsquo;s the &lt;a href=&#34;https://github.com/sanand0/geocode-excel&#34;&gt;Github project&lt;/a&gt; with a downloadable &lt;a href=&#34;https://github.com/sanand0/geocode-excel/raw/master/Geocode.xlsm&#34;&gt;Excel file&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;This is via Visual Basic code for a &lt;code&gt;GoogleGeocode&lt;/code&gt; function that &lt;a href=&#34;https://developers.google.com/maps/documentation/geocoding/&#34;&gt;geocodes&lt;/a&gt; addresses.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-javascript&#34; data-lang=&#34;javascript&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nb&#34;&gt;Function&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;GoogleGeocode&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;address&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;As&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;As&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;String&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nx&#34;&gt;Dim&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;xDoc&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;As&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;New&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;MSXML2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;DOMDocument&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nx&#34;&gt;xDoc&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;kr&#34;&gt;async&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;False&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nx&#34;&gt;xDoc&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;Load&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;http://maps.googleapis.com/maps/api/geocode/&amp;#34;&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;+&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;_&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;s2&#34;&gt;&amp;#34;xml?address=&amp;#34;&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;+&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;address&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;+&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;&amp;amp;sensor=false&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nx&#34;&gt;If&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;xDoc&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;parseError&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;ErrorCode&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;lt;&amp;gt;&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;0&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;Then&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;nx&#34;&gt;GoogleGeocode&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;xDoc&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;parseError&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;reason&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nx&#34;&gt;Else&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;nx&#34;&gt;xDoc&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;setProperty&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;SelectionLanguage&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;XPath&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;nx&#34;&gt;lat&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;xDoc&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;SelectSingleNode&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;//lat&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;).&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;Text&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;nx&#34;&gt;lng&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;xDoc&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;SelectSingleNode&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;//lng&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;).&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;Text&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;nx&#34;&gt;GoogleGeocode&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;lat&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;,&amp;#34;&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;lng&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nx&#34;&gt;End&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;If&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nx&#34;&gt;End&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;Function&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;hr&gt;
&lt;h2 id=&#34;comments&#34;&gt;Comments&lt;/h2&gt;
&lt;!-- wp-comments-start --&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Ryan&lt;/strong&gt; &lt;em&gt;8 Jun 2015 9:28 pm&lt;/em&gt;:
I find this isn&amp;rsquo;t working and says, Compile Error; User defined type not defined
xDoc As New MSXML2.DOMDocument what do I change to fix it?
Thank you&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Richie Lionell&lt;/strong&gt; &lt;em&gt;27 Jul 2016 6:40 am&lt;/em&gt;:
Ryan, Inside the VBE, Go to Tools -&amp;gt; References, then Select Microsoft XML, v6.0 . If that doesn&amp;rsquo;t work unselect that and select Microsoft XML, v3.0&lt;/li&gt;
&lt;/ul&gt;
&lt;!-- wp-comments-end --&gt;
</description>
    </item>
    <item>
      <title>Automating PowerPoint with Python</title>
      <link>https://www.s-anand.net/blog/automating-powerpoint-with-python/</link>
      <pubDate>Thu, 02 Apr 2009 20:22:36 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/automating-powerpoint-with-python/</guid>
      <description>&lt;p&gt;&lt;img alt=&#34;Automating PowerPoint with Python&#34; loading=&#34;lazy&#34; src=&#34;https://www.s-anand.net/blog/assets/automating-powerpoint-with-python.webp&#34;&gt;&lt;/p&gt;
&lt;p&gt;Writing a program to draw or change slides is sometimes easier than doing it manually. To change all fonts on a presentation to Arial, for example, you’d write this Visual Basic macro:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-vb&#34; data-lang=&#34;vb&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;Sub&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;Arial&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;For&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;Each&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Slide&lt;/span&gt; &lt;span class=&#34;ow&#34;&gt;In&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;ActivePresentation&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Slides&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;k&#34;&gt;For&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;Each&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Shape&lt;/span&gt; &lt;span class=&#34;ow&#34;&gt;In&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Slide&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Shapes&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;            &lt;span class=&#34;n&#34;&gt;Shape&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;TextFrame&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;TextRange&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Font&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Name&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;&amp;#34;Arial&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;k&#34;&gt;Next&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;Next&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;End&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;Sub&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If you didn’t like Visual Basic, though, you &lt;strong&gt;could&lt;/strong&gt; write the same thing in Python:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kn&#34;&gt;import&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;win32com.client&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;sys&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;Application&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;win32com&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;client&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Dispatch&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;PowerPoint.Application&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;Application&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Visible&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;kc&#34;&gt;True&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;Presentation&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Application&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Presentations&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Open&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;sys&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;argv&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;])&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;for&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Slide&lt;/span&gt; &lt;span class=&#34;ow&#34;&gt;in&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Presentation&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Slides&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;k&#34;&gt;for&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Shape&lt;/span&gt; &lt;span class=&#34;ow&#34;&gt;in&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Slide&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Shapes&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;n&#34;&gt;Shape&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;TextFrame&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;TextRange&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Font&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Name&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;Arial&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;Presentation&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Save&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;Application&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Quit&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Save this as &lt;code&gt;arial.py&lt;/code&gt; and type &lt;code&gt;“arial.py some.ppt”&lt;/code&gt; to convert &lt;code&gt;some.ppt&lt;/code&gt; into Arial.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://www.s-anand.net/blog/assets/flickr-powerpoint-in-python_3404204235_o-png.webp&#34;&gt;&lt;img alt=&#34;Screenshot of Python controlling PowerPoint&#34; loading=&#34;lazy&#34; src=&#34;https://www.s-anand.net/blog/assets/flickr-powerpoint-in-python_3404204235_o-png.webp&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Let’s break that down a bit. &lt;code&gt;import win32com.client&lt;/code&gt; lets you interact with Windows using &lt;a href=&#34;http://en.wikipedia.org/wiki/Component_Object_Model&#34;&gt;COM&lt;/a&gt;. You need &lt;a href=&#34;http://www.activestate.com/activepython/&#34;&gt;ActivePython&lt;/a&gt; to do this. Now you can launch PowerPoint with&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;Application&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;win32com&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;client&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Dispatch&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;PowerPoint.Application&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The Application object you get here is the same Application object you’d use in Visual Basic. That’s pretty powerful. What that means is, to a good extent, you can copy and paste Visual Basic code into Python and expect it to work with minor tweaks for language syntax, just please make sure to learn &lt;a href=&#34;https://blog.couchbase.com/tips-and-tricks-for-upgrading-from-python-2-to-python-3/&#34;&gt;how to update python&lt;/a&gt; before doing anything else.&lt;/p&gt;
&lt;p&gt;So let’s try to do something with this. First, let’s open PowerPoint and add a blank slide.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# Open PowerPoint&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;Application&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;win32com&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;client&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Dispatch&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;PowerPoint.Application&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# Create new presentation&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;Presentation&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Application&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Presentations&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Add&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# Add a blank slide&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;Slide&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Presentation&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Slides&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Add&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;12&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;That 12 is the code for a blank slide. In Visual Basic, you’d instead say:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;Slide&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Presentation&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Slides&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Add&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;ppLayoutBlank&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To do this in Python, run &lt;code&gt;Python/Lib/site-packages/win32com/client/makepy.py&lt;/code&gt; and pick “Microsoft Office 12.0 Object Library” and “Microsoft PowerPoint 12.0 Object Library”. (If you have a version of Office other than 12.0, pick your version.)&lt;/p&gt;
&lt;p&gt;This creates two Python files. I rename these files as &lt;code&gt;MSO.py&lt;/code&gt; and &lt;code&gt;MSPPT.py&lt;/code&gt; and do this:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kn&#34;&gt;import&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;MSO&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;MSPPT&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;g&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;globals&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;for&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;c&lt;/span&gt; &lt;span class=&#34;ow&#34;&gt;in&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;dir&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;MSO&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;constants&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;):&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;g&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;c&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;]&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;getattr&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;MSO&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;constants&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;c&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;for&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;c&lt;/span&gt; &lt;span class=&#34;ow&#34;&gt;in&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;dir&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;MSPPT&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;constants&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;):&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;g&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;c&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;]&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;getattr&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;MSPPT&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;constants&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;c&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;This makes constants like &lt;code&gt;ppLayoutBlank&lt;/code&gt;, &lt;code&gt;msoShapeRectangle&lt;/code&gt;, etc. available. So now I can create a blank slide and add a rectangle Python just like in Visual Basic:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;Slide&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Presentation&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Slides&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Add&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;ppLayoutBlank&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;Slide&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Shapes&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;AddShape&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;msoShapeRectangle&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;100&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;100&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;200&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;200&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Incidentally, the dimensions are in points (1/72&amp;quot;). Since the default presentation is 10&amp;quot; x 7.5&amp;quot; the size of each page is 720 x 540.&lt;/p&gt;
&lt;p&gt;Let’s do something that you’d have trouble doing manually in PowerPoint: a &lt;a href=&#34;http://www.cs.umd.edu/hcil/treemap-history/&#34;&gt;Treemap&lt;/a&gt;. &lt;a href=&#34;http://www.guardian.co.uk/&#34;&gt;The Guardian’s&lt;/a&gt; &lt;a href=&#34;http://www.guardian.co.uk/data-store&#34;&gt;data store&lt;/a&gt; kindly makes available the &lt;a href=&#34;http://spreadsheets.google.com/pub?key=phNtm3LmDZEOoyu8eDzdSXw&#34;&gt;top 50 banks by assets&lt;/a&gt; that we’ll use for this example. Our target output is a simple Treemap visualisation.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://www.s-anand.net/blog/assets/flickr-treemap_3407796884_o-jpg.webp&#34;&gt;&lt;img alt=&#34;Treemap&#34; loading=&#34;lazy&#34; src=&#34;https://www.s-anand.net/blog/assets/flickr-treemap_3407796884_o-jpg.webp&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;We’ll start by creating a blank slide. The code is as before.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kn&#34;&gt;import&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;win32com.client&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;MSO&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;MSPPT&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;g&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;globals&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;for&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;c&lt;/span&gt; &lt;span class=&#34;ow&#34;&gt;in&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;dir&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;MSO&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;constants&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;):&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;g&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;c&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;]&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;getattr&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;MSO&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;constants&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;c&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;for&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;c&lt;/span&gt; &lt;span class=&#34;ow&#34;&gt;in&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;dir&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;MSPPT&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;constants&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;):&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;g&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;c&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;]&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;getattr&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;MSPPT&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;constants&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;c&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;Application&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;win32com&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;client&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Dispatch&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;PowerPoint.Application&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;Application&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Visible&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;kc&#34;&gt;True&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;Presentation&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Application&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Presentations&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Add&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;()&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;Slide&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Presentation&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Slides&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Add&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;ppLayoutBlank&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Now let&amp;rsquo;s import data from The Guardian. The spreadsheet is available at &lt;a href=&#34;http://spreadsheets.google.com/pub?key=phNtm3LmDZEOoyu8eDzdSXw&#34; title=&#34;http://spreadsheets.google.com/pub?key=phNtm3LmDZEOoyu8eDzdSXw&#34;&gt;http://spreadsheets.google.com/pub?key=phNtm3LmDZEOoyu8eDzdSXw&lt;/a&gt; and we can get just the banks and assets as a CSV file by adding &lt;code&gt;&amp;amp;output=csv&amp;amp;range=B2:C51&lt;/code&gt; (via &lt;a href=&#34;http://ouseful.wordpress.com/2009/03/10/using-many-eyes-wikified-to-visualise-guardian-data-store-data-on-google-docs/&#34;&gt;OUseful.Info&lt;/a&gt;).&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kn&#34;&gt;import&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;urllib2&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;csv&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;url&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;http://spreadsheets.google.com/pub?key=phNtm3LmDZEOoyu8eDzdSXw&amp;amp;output=csv&amp;amp;range=B2:C51&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# Open the URL using a CSV reader&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;reader&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;csv&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;reader&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;urllib2&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;urlopen&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;url&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;))&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# Convert the CSV into a list of (asset-size, bank-name) tuples&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;data&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;list&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;((&lt;/span&gt;&lt;span class=&#34;nb&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;s&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;replace&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;,&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)),&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;b&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;decode&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;utf8&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;))&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;for&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;b&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;s&lt;/span&gt; &lt;span class=&#34;ow&#34;&gt;in&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;reader&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;I created a simple Treemap class based on the &lt;a href=&#34;http://www.win.tue.nl/~vanwijk/stm.pdf&#34;&gt;squarified algorithm&lt;/a&gt; — you can play with the &lt;a href=&#34;https://files.s-anand.net/blog/a/treemap.zip&#34;&gt;source code&lt;/a&gt;. This Treemap class can be fed the data in the format we have, and a draw function. The draw function takes (x, y, width, height, data_item) as parameters, where data_item is a row in the data list that we pass to it.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-python&#34; data-lang=&#34;python&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;def&lt;/span&gt; &lt;span class=&#34;nf&#34;&gt;draw&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;x&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;y&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;w&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;h&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;n&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;):&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;c1&#34;&gt;# Draw the box&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;shape&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Slide&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Shapes&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;AddShape&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;msoShapeRectangle&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;x&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;y&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;w&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;h&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;c1&#34;&gt;# Add text: bank name (asset size in millions)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;shape&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;TextFrame&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;TextRange&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Text&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;n&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;1&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;]&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;+&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34; (&amp;#34;&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;+&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;str&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nb&#34;&gt;int&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;n&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;[&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;0&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;]&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;/&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;1000&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;+&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;500&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;))&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;+&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;M)&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;c1&#34;&gt;# Reduce left and right margins&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;shape&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;TextFrame&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;MarginLeft&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;shape&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;TextFrame&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;MarginRight&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;c1&#34;&gt;# Use 12pt font&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;n&#34;&gt;shape&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;TextFrame&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;TextRange&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Font&lt;/span&gt;&lt;span class=&#34;o&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Size&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;12&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;kn&#34;&gt;from&lt;/span&gt; &lt;span class=&#34;nn&#34;&gt;Treemap&lt;/span&gt; &lt;span class=&#34;kn&#34;&gt;import&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;Treemap&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;c1&#34;&gt;# 720pt x 540pt is the size of the slide.&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;Treemap&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;mi&#34;&gt;720&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;mi&#34;&gt;540&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;data&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;draw&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;Try running the &lt;a href=&#34;https://files.s-anand.net/blog/a/treemap.zip&#34;&gt;source code&lt;/a&gt;. You should have a single slide in PowerPoint like this.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://www.s-anand.net/blog/assets/flickr-treemap-plain_3407796888_o-jpg.webp&#34;&gt;&lt;img alt=&#34;Plain Treemap&#34; loading=&#34;lazy&#34; src=&#34;https://www.s-anand.net/blog/assets/flickr-treemap-plain_3407796888_o-jpg.webp&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The beauty of using PowerPoint as the output format is that converting this into a cushioned Treemap with gradients like below (or changing colours, for that matter), is a simple interactive process.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://www.s-anand.net/blog/assets/flickr-treemap-powerpoint_3407820202_o-png.webp&#34;&gt;&lt;img alt=&#34;Treemap in PowerPoint&#34; loading=&#34;lazy&#34; src=&#34;https://www.s-anand.net/blog/assets/flickr-treemap-powerpoint_3407820202_o-png.webp&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&#34;comments&#34;&gt;Comments&lt;/h2&gt;
&lt;!-- wp-comments-start --&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&#34;http://python-catalin.blogspot.com/&#34;&gt;Catalin&lt;/a&gt;&lt;/strong&gt; &lt;em&gt;5 Apr 2009 8:01 am&lt;/em&gt;:
Very interesting article. I think python may be the best solution on programming .
Do you worked with python and openoffice ?&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&#34;http://mb.netsons.org&#34;&gt;Michele&lt;/a&gt;&lt;/strong&gt; &lt;em&gt;5 Apr 2009 10:35 am&lt;/em&gt;:
Very very interesting. The treemap integration is absolutely phenomenal.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&#34;http://www.third-bit.com&#34;&gt;Greg Wilson&lt;/a&gt;&lt;/strong&gt; &lt;em&gt;3 Apr 2009 9:46 pm&lt;/em&gt;:
Thanks very much for posting this &amp;mdash; much appreciated. One question: how do you find documentation on the PowerPoint API? Is it just the same as the VB (with appropriate substitutions)? Or&amp;hellip;?&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&#34;http://www.s-anand.net/&#34;&gt;S Anand&lt;/a&gt;&lt;/strong&gt; &lt;em&gt;5 Apr 2009 4:15 pm&lt;/em&gt;:
Never worked with OpenOffice, I&amp;rsquo;m afraid. If I don&amp;rsquo;t use Microsoft Office, my next preference would be Google&amp;rsquo;s online offerings, I guess. But either way, Python&amp;rsquo;s an elegant choice.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&#34;http://www.s-anand.net/&#34;&gt;S Anand&lt;/a&gt;&lt;/strong&gt; &lt;em&gt;4 Apr 2009 6:59 am&lt;/em&gt;:
It&amp;rsquo;s the same as with VB. I just press Shift-F1 on VB in PowerPoint and search for the keywords. Usually, it&amp;rsquo;s quite intuitive.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&#34;http://crankycoder.com/2009/05/07/links-for-may-7th/&#34;&gt;crankycoder.com » Links for May 7th&lt;/a&gt;&lt;/strong&gt; &lt;em&gt;7 May 2009 5:06 pm&lt;/em&gt; &lt;em&gt;(pingback)&lt;/em&gt;:
[&amp;hellip;] Automating PowerPoint with Python - [&amp;hellip;]&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&#34;http://www.powerpoint.in&#34;&gt;Raj&lt;/a&gt;&lt;/strong&gt; &lt;em&gt;24 May 2009 7:03 pm&lt;/em&gt;:
Its all Intresting Anand&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&#34;http://www.s-anand.net/blog/round-buttons-with-python-image-library/&#34;&gt;Round buttons with Python Image Library | s-anand.net&lt;/a&gt;&lt;/strong&gt; &lt;em&gt;11 Jun 2009 10:41 am&lt;/em&gt; &lt;em&gt;(pingback)&lt;/em&gt;:
[&amp;hellip;] it using PowerPoint via Python and export as a PNG.So we make a curved box, put in the appropriate gradients and borders, and [&amp;hellip;]&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&#34;http://financialpython.wordpress.com/2009/08/08/python-and-powerpoint/&#34;&gt;Python and Powerpoint « Financial Python&lt;/a&gt;&lt;/strong&gt; &lt;em&gt;8 Aug 2009 8:48 pm&lt;/em&gt; &lt;em&gt;(pingback)&lt;/em&gt;:
[&amp;hellip;] I’d almost forgotten since I’ve been using a Mac for a while. Anyway, I ran across this short tutorial on using COM and Python to automate the creation of powerpoint slides. I used COM with excel a [&amp;hellip;]&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Stef&lt;/strong&gt; &lt;em&gt;17 Jul 2010 7:41 pm&lt;/em&gt;:
Hi,
I have created a program based on the example you showed on this page (creation of ppt slides with txt and images based on info in a CSV file)
It works fine on my PC but when I compile it with py2exe, the prog works on my computer but not on another. Any idea of what I should do so that someone who didn&amp;rsquo;t install ActivePython can use the prog?
Stef&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Layne Seely&lt;/strong&gt; &lt;em&gt;2 Feb 2011 5:13 pm&lt;/em&gt;:
I can follow the examples above to open a presentation, however, can you open the presentation to a particular slide?&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;tom tan&lt;/strong&gt; &lt;em&gt;21 May 2012 1:35 pm&lt;/em&gt;:
Great writing. Helps me to get the hang of office automation with python in general. Thanks.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Lolla&lt;/strong&gt; &lt;em&gt;2 Dec 2013 12:22 pm&lt;/em&gt;:
How to make this work with arabic text?&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Chad Kijewski&lt;/strong&gt; &lt;em&gt;25 Jun 2013 10:40 pm&lt;/em&gt;:
Beautiful, thank you for the quick but effective tutorial. I never thought that I&amp;rsquo;d ever be as excited about PowerPoint as I am, but as usual Python can make anything fun.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&#34;http://www.twrilla.org&#34;&gt;Roger&lt;/a&gt;&lt;/strong&gt; &lt;em&gt;7 Aug 2013 3:02 pm&lt;/em&gt;:
Just a heads up, you can add notes via the following command:
notes_range = slide.NotesPage.Shapes(2)
notes_range.TextFrame.TextRange.Text = snote
And to use a solid color for a background:
def RGB(r,g,b):
return r*256**2 + g*256 + b
slide_master.Background.Fill.ForeColor.RGB = RGB(256,256,256)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;blerb&lt;/strong&gt; &lt;em&gt;23 Apr 2014 9:12 pm&lt;/em&gt;:
My wife needs a way to easily export all comments (comments, not notes) from a powerpoint, which is not a native feature. I was looking at python-pptx module but it only supports 2.6, 2.7. I don&amp;rsquo;t want to downgrade from 3.
Does win32com have a python3 version and could it be used for this?&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Zach&lt;/strong&gt; &lt;em&gt;20 Aug 2015 4:59 pm&lt;/em&gt;:
I am very much a beginner with coding in general but am trying to follow along here and am confused on what I am sure is a very basic issue, so bear with me.
At the point where you say, &amp;ldquo;To do this in Python, run Python/Lib/site-packages/win32com/client/makepy.py and pick “Microsoft Office 12.0 Object Library” and “Microsoft PowerPoint 12.0 Object Library”. (If you have a version of Office other than 12.0, pick your version.)&amp;rdquo; I am unable to run this as there is no win32com directory. I am able to import and utilize the win32com.client library just fine (It pulls up PowerPoint and creates slides) but getting the whole MSO and MSPPT part setup is confusing me. Any help or advice is appreciated, thanks!&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Vasanth&lt;/strong&gt; &lt;em&gt;21 Jul 2016 10:09 am&lt;/em&gt;:
Hi Anand,
I am unable to import MSO &amp;amp; MSPPT. I renamed py files created in gen_py. I am using 2.7.12 64 bit.
ImportError: No module named MSO
Please suggest ?&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Afiz&lt;/strong&gt; &lt;em&gt;30 Jan 2016 10:17 am&lt;/em&gt;:
Hi Anand,
Thanks for this wonderful tutorial. I tried to run makepy.py file as you mentioned above, but I didn&amp;rsquo;t see any files getting created after running the file. Could you please tell me , what I might be missing??
Thanks again.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Sruti&lt;/strong&gt; &lt;em&gt;24 Jul 2017 8:23 am&lt;/em&gt;:
Hi Anand,
I&amp;rsquo;m facing an issue similar to Vasanth&amp;rsquo;s
I&amp;rsquo;m not able to find “Microsoft PowerPoint 12.0 Object Library”. Also I get the error shown below:
for c in dir(PSO.constants): g[c] = getattr(PSO.constants, c)
AttributeError: &amp;lsquo;module&amp;rsquo; object has no attribute &amp;lsquo;constants&amp;rsquo;
Any help here is appreciated. Mine is a 64 bit system using Python 2.7.13 version&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Balu&lt;/strong&gt; &lt;em&gt;6 Mar 2016 12:22 pm&lt;/em&gt;:
Hi Anand,
How to add buttons in powerpoint 2013 ribbon through python?
Thanks for the support.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&#34;http://www.halifa.net&#34;&gt;scratch&lt;/a&gt;&lt;/strong&gt; &lt;em&gt;16 Jan 2017 2:02 am&lt;/em&gt;:
your python is very good ,I benifit from it ,thanks. I am a chinese,my english is not good ,sorry.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Mj&lt;/strong&gt; &lt;em&gt;10 Mar 2018 12:37 am&lt;/em&gt;:
Why not try &lt;a href=&#34;https://www.pptxbuilder.com&#34;&gt;www.pptxbuilder.com&lt;/a&gt;. Upload your data, customize your data in visual form, then download everything in a powerpoint presentation.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Sailakshmi&lt;/strong&gt; &lt;em&gt;18 Jul 2017 6:39 am&lt;/em&gt;:
Is there any method by which I could automate slideshow using python?&lt;/li&gt;
&lt;/ul&gt;
&lt;!-- wp-comments-end --&gt;
</description>
    </item>
    <item>
      <title>Motion charts in Excel</title>
      <link>https://www.s-anand.net/blog/motion-charts-in-excel/</link>
      <pubDate>Thu, 12 Mar 2009 13:56:26 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/motion-charts-in-excel/</guid>
      <description>&lt;p&gt;Creating &lt;a href=&#34;http://www.google.com/search?q=motion+chart&#34;&gt;motion charts&lt;/a&gt; in Excel is a simple four-step process.&lt;/p&gt; &lt;ol&gt; &lt;li&gt;Get the data in a tabular format with the columns [date, item, x, y, size]  &lt;/li&gt;&lt;li&gt;Make a “today” cell, and create a lookup table for “today”  &lt;/li&gt;&lt;li&gt;Make a bubble chart with that lookup table  &lt;/li&gt;&lt;li&gt;Add a scroll bar and a play button linked to the “today” cell&lt;/li&gt;&lt;/ol&gt; &lt;p&gt;For the impatient, here’s a &lt;a href=&#34;https://files.s-anand.net/blog/a/motion-chart.xls&#34;&gt;motion chart spreadsheet&lt;/a&gt; that you can tailor to your needs.&lt;br&gt;For the patient and the puzzled, here’s a quick introduction to bubble and motion charts.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;What is a bubble chart?&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;A bubble chart is a way of capturing 3 dimensions. For example, the chart below could be the birth, literacy rate and population of countries (X-axis, Y-axis and size). Or the growth, margin and market cap of companies. &lt;/p&gt; &lt;p&gt;&lt;a title=&#34;Bubble chart&#34; href=&#34;https://www.s-anand.net/blog/assets/flickr-bubble-chart_3348447675_o-png.webp&#34;&gt;&lt;img height=&#34;300&#34; alt=&#34;Example of a bubble chart&#34; src=&#34;https://www.s-anand.net/blog/assets/flickr-bubble-chart_3348447675_o-png.webp&#34; width=&#34;450&#34;&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;It lets you compare three dimensions at a glance. The size dimension is a different from the X and Y axes, though. It’s not easy to compare differences in size. And the eye tends to focus on the big objects. So usually, size is used highlight important things, and the X and Y axes used to measure the performance of these things.&lt;/p&gt; &lt;p&gt;If I were to summarise bubble charts in a sentence, it would be: &lt;em&gt;bubble charts show the performance of important things (in two dimensions)&lt;/em&gt;. (In contrast, &lt;a href=&#34;https://www.s-anand.net/blog/visualisation-centralising-improves-productivity/&#34;&gt;Variwide charts&lt;/a&gt; show the same on one dimension.)&lt;/p&gt; &lt;p&gt;Say you’re a services firm. You want to track the productivity of your most &lt;em&gt;expensive&lt;/em&gt; groups (“the important things”). Productivity is measured by 2 parameters: &lt;em&gt;utilisation&lt;/em&gt; and &lt;em&gt;margin&lt;/em&gt;. The bubble chart would then have the &lt;em&gt;expense&lt;/em&gt; of each group as the size, and its &lt;em&gt;utilisation&lt;/em&gt; and &lt;em&gt;contribution&lt;/em&gt; as the X and Y axes.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;What is a motion chart?&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Motion charts are animated bubble charts. &lt;em&gt;They &lt;font color=&#34;#ff0000&#34;&gt;track &lt;/font&gt;the performance of important things over time (in two dimensions)&lt;/em&gt;. This is chart with 4 dimensions. But not all data with 4 dimensions can be plotted as a motion chart. One dimension has to be time, and another has to be linked to the importance of the item.&lt;/p&gt;&lt;object classid=&#34;clsid:D27CDB6E-AE6D-11cf-96B8-444553540000&#34; codebase=&#34;http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0&#34; width=&#34;451&#34; height=&#34;334&#34; id=&#34;motion-chart.swf&#34;&gt;  &lt;param name=&#34;movie&#34; value=&#34;/a/motion-chart.swf&#34;&gt;  &lt;param name=&#34;quality&#34; value=&#34;high&#34;&gt;  &lt;param name=&#34;bgcolor&#34; value=&#34;#ffffff&#34;&gt;  &lt;embed src=&#34;https://www.s-anand.net/blog/a/motion-chart.swf&#34; quality=&#34;high&#34; bgcolor=&#34;#ffffff&#34; width=&#34;451&#34; height=&#34;334&#34; name=&#34;motion-chart.swf&#34; type=&#34;application/x-shockwave-flash&#34; pluginspage=&#34;http://www.macromedia.com/go/getflashplayer&#34;&gt;&lt;/embed&gt;  &lt;/object&gt; &lt;p&gt;&amp;nbsp;&lt;/p&gt; &lt;p&gt;Motion charts were pioneered by &lt;a href=&#34;http://en.wikipedia.org/wiki/Hans_Rosling&#34;&gt;Hans Rosling&lt;/a&gt; and his &lt;a href=&#34;http://www.ted.com/index.php/talks/hans_rosling_shows_the_best_stats_you_ve_ever_seen.html&#34;&gt;TED Talk&lt;/a&gt; shows you the true power of motion charts.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;How do I create these charts?&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt; &lt;p&gt;Use the &lt;a href=&#34;http://www.google.com/ig/directory?url=www.google.com/ig/modules/motionchart.xml&#34;&gt;Motion Chart Gadget&lt;/a&gt; to display any of your data on a web page. Or use &lt;a href=&#34;http://docs.google.com/&#34;&gt;Google Spreadsheets&lt;/a&gt; if you need to see the chart on a spreadsheet: motion charts are built in. &lt;/p&gt; &lt;p&gt;If you or your viewer don’t have access to these, and you want to use Excel, here’s how.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;1. Get the data in a tabular format&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Get the data in the format below. You need the X, Y and size for &lt;em&gt;each thing&lt;/em&gt;, for &lt;em&gt;each date&lt;/em&gt;.&lt;/p&gt; &lt;table class=&#34;lines numbers&#34;&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt;&lt;strong&gt;Date&lt;/strong&gt;&lt;/td&gt; &lt;td&gt;&lt;strong&gt;Thing&lt;/strong&gt;&lt;/td&gt; &lt;td&gt;&lt;strong&gt;X&lt;/strong&gt;&lt;/td&gt; &lt;td&gt;&lt;strong&gt;Y&lt;/strong&gt;&lt;/td&gt; &lt;td&gt;&lt;strong&gt;Size&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;08/02/2009&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;64%&lt;/td&gt; &lt;td&gt;11%&lt;/td&gt; &lt;td&gt;1&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;08/02/2009&lt;/td&gt; &lt;td&gt;B&lt;/td&gt; &lt;td&gt;14%&lt;/td&gt; &lt;td&gt;33%&lt;/td&gt; &lt;td&gt;2&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;08/02/2009&lt;/td&gt; &lt;td&gt;C&lt;/td&gt; &lt;td&gt;78%&lt;/td&gt; &lt;td&gt;55%&lt;/td&gt; &lt;td&gt;3&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;08/02/2009&lt;/td&gt; &lt;td&gt;D&lt;/td&gt; &lt;td&gt;57%&lt;/td&gt; &lt;td&gt;73%&lt;/td&gt; &lt;td&gt;4&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;08/02/2009&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;39%&lt;/td&gt; &lt;td&gt;32%&lt;/td&gt; &lt;td&gt;5&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;08/02/2009&lt;/td&gt; &lt;td&gt;F&lt;/td&gt; &lt;td&gt;40%&lt;/td&gt; &lt;td&gt;81%&lt;/td&gt; &lt;td&gt;6&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;09/02/2009&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;64%&lt;/td&gt; &lt;td&gt;12%&lt;/td&gt; &lt;td&gt;1&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;09/02/2009&lt;/td&gt; &lt;td&gt;B&lt;/td&gt; &lt;td&gt;14%&lt;/td&gt; &lt;td&gt;33%&lt;/td&gt; &lt;td&gt;2&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;09/02/2009&lt;/td&gt; &lt;td&gt;C&lt;/td&gt; &lt;td&gt;78%&lt;/td&gt; &lt;td&gt;56%&lt;/td&gt; &lt;td&gt;3&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;09/02/2009&lt;/td&gt; &lt;td&gt;D&lt;/td&gt; &lt;td&gt;57%&lt;/td&gt; &lt;td&gt;73%&lt;/td&gt; &lt;td&gt;4&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;09/02/2009&lt;/td&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;39%&lt;/td&gt; &lt;td&gt;32%&lt;/td&gt; &lt;td&gt;5&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;09/02/2009&lt;/td&gt; &lt;td&gt;F&lt;/td&gt; &lt;td&gt;40%&lt;/td&gt; &lt;td&gt;81%&lt;/td&gt; &lt;td&gt;6&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;…&lt;/td&gt; &lt;td&gt;…&lt;/td&gt; &lt;td&gt;…&lt;/td&gt; &lt;td&gt;…&lt;/td&gt; &lt;td&gt;..&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p&gt;To make life (and lookups) easier, add a column called “Key” which concatenates the date and the things. Typing “=A2&amp;amp;B2” will concatenate cells A2 and B2. (&lt;font color=&#34;#ff0000&#34;&gt;Red cells&lt;/font&gt; use formulas.)&lt;/p&gt; &lt;table class=&#34;lines numbers&#34;&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt;Date&lt;/td&gt; &lt;td&gt;Thing&lt;/td&gt; &lt;td&gt;Key&lt;/td&gt; &lt;td&gt;X&lt;/td&gt; &lt;td&gt;Y&lt;/td&gt; &lt;td&gt;Size&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;08/02/2009&lt;/td&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;&lt;font color=&#34;#ff0000&#34;&gt;39852A&lt;/font&gt;&lt;/td&gt; &lt;td&gt;64%&lt;/td&gt; &lt;td&gt;11%&lt;/td&gt; &lt;td&gt;1&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;08/02/2009&lt;/td&gt; &lt;td&gt;B&lt;/td&gt; &lt;td&gt;&lt;font color=&#34;#ff0000&#34;&gt;39852B&lt;/font&gt;&lt;/td&gt; &lt;td&gt;14%&lt;/td&gt; &lt;td&gt;33%&lt;/td&gt; &lt;td&gt;2&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;08/02/2009&lt;/td&gt; &lt;td&gt;C&lt;/td&gt; &lt;td&gt;&lt;font color=&#34;#ff0000&#34;&gt;39852C&lt;/font&gt;&lt;/td&gt; &lt;td&gt;78%&lt;/td&gt; &lt;td&gt;55%&lt;/td&gt; &lt;td&gt;3&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;08/02/2009&lt;/td&gt; &lt;td&gt;D&lt;/td&gt; &lt;td&gt;&lt;font color=&#34;#ff0000&#34;&gt;39852D&lt;/font&gt;&lt;/td&gt; &lt;td&gt;57%&lt;/td&gt; &lt;td&gt;73%&lt;/td&gt; &lt;td&gt;4&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;…&lt;/td&gt; &lt;td&gt;…&lt;/td&gt; &lt;td&gt;…&lt;/td&gt; &lt;td&gt;…&lt;/td&gt; &lt;td&gt;…&lt;/td&gt; &lt;td&gt;…&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p&gt;&lt;strong&gt;2. Make a “today” cell, and create a lookup table for “today”&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Create a cell called “Offset” and type in 0 as its value. Add another cell called Today whose value is the start date (08/02/2009 in this case) plus the offset (0 in this case)&lt;/p&gt; &lt;table class=&#34;lines&#34;&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt;Offset&lt;/td&gt; &lt;td&gt;0&lt;/td&gt; &lt;td&gt;(Just type 0)&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Today&lt;/td&gt; &lt;td&gt;&lt;font color=&#34;#ff0000&#34;&gt;08/02/2009&lt;/font&gt;&lt;/td&gt; &lt;td&gt;Use a formula: =STARTDATE + OFFSET&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p&gt;Now, if you change the offset from 0 to 1, “Today” changes to 09/02/2009. By changing just this one cell, we can create a table that holds the bubble chart details for that day, like below.&lt;/p&gt; &lt;table class=&#34;lines&#34;&gt; &lt;tbody&gt; &lt;tr&gt; &lt;td&gt;&lt;strong&gt;Thing&lt;/strong&gt;&lt;/td&gt; &lt;td&gt;&lt;strong&gt;X&lt;/strong&gt;&lt;/td&gt; &lt;td&gt;&lt;strong&gt;Y&lt;/strong&gt;&lt;/td&gt; &lt;td&gt;&lt;strong&gt;Size&lt;/strong&gt;&lt;/td&gt; &lt;td&gt;&lt;strong&gt;Formula&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;A&lt;/td&gt; &lt;td&gt;&lt;font color=&#34;#ff0000&#34;&gt;44%&lt;/font&gt;&lt;/td&gt; &lt;td&gt;&lt;font color=&#34;#ff0000&#34;&gt;19%&lt;/font&gt;&lt;/td&gt; &lt;td&gt;&lt;font color=&#34;#ff0000&#34;&gt;1&lt;/font&gt;&lt;/td&gt; &lt;td rowspan=&#34;6&#34;&gt; &lt;p&gt;X =VLOOKUP(TODAY &amp;amp; THING, DATA, 2, 0)&lt;/p&gt; &lt;p&gt;Y =VLOOKUP(TODAY &amp;amp; THING, DATA, 3, 0)&lt;/p&gt; &lt;p&gt;Size =VLOOKUP(TODAY &amp;amp; THING, DATA, 4, 0)&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;B&lt;/td&gt; &lt;td&gt;&lt;font color=&#34;#ff0000&#34;&gt;6%&lt;/font&gt;&lt;/td&gt; &lt;td&gt;&lt;font color=&#34;#ff0000&#34;&gt;13%&lt;/font&gt;&lt;/td&gt; &lt;td&gt;&lt;font color=&#34;#ff0000&#34;&gt;2&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;C&lt;/td&gt; &lt;td&gt;&lt;font color=&#34;#ff0000&#34;&gt;90%&lt;/font&gt;&lt;/td&gt; &lt;td&gt;&lt;font color=&#34;#ff0000&#34;&gt;71%&lt;/font&gt;&lt;/td&gt; &lt;td&gt;&lt;font color=&#34;#ff0000&#34;&gt;3&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;D&lt;/td&gt; &lt;td&gt;&lt;font color=&#34;#ff0000&#34;&gt;41%&lt;/font&gt;&lt;/td&gt; &lt;td&gt;&lt;font color=&#34;#ff0000&#34;&gt;61%&lt;/font&gt;&lt;/td&gt; &lt;td&gt;&lt;font color=&#34;#ff0000&#34;&gt;4&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;E&lt;/td&gt; &lt;td&gt;&lt;font color=&#34;#ff0000&#34;&gt;59%&lt;/font&gt;&lt;/td&gt; &lt;td&gt;&lt;font color=&#34;#ff0000&#34;&gt;40%&lt;/font&gt;&lt;/td&gt; &lt;td&gt;&lt;font color=&#34;#ff0000&#34;&gt;5&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;F&lt;/td&gt; &lt;td&gt;&lt;font color=&#34;#ff0000&#34;&gt;16%&lt;/font&gt;&lt;/td&gt; &lt;td&gt;&lt;font color=&#34;#ff0000&#34;&gt;77%&lt;/font&gt;&lt;/td&gt; &lt;td&gt;&lt;font color=&#34;#ff0000&#34;&gt;6&lt;/font&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt; &lt;p&gt;Check out my &lt;a href=&#34;https://files.s-anand.net/blog/a/motion-chart.xls&#34;&gt;motion chart spreadsheet&lt;/a&gt; to see how these are constructed.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;3. Make a bubble chart with that lookup table&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;This is a simple Insert – Chart. Go through the chart types and select bubble. Play around with the data selection until you get the X, Y and Size columns right.&lt;/p&gt; &lt;p&gt;&lt;a title=&#34;Bubble chart&#34; href=&#34;https://www.s-anand.net/blog/assets/flickr-bubble-chart_3348447675_o-png.webp&#34;&gt;&lt;img height=&#34;300&#34; alt=&#34;Example of a bubble chart&#34; src=&#34;https://www.s-anand.net/blog/assets/flickr-bubble-chart_3348447675_o-png.webp&#34; width=&#34;450&#34;&gt;&lt;/a&gt;&lt;/p&gt; &lt;p&gt;&lt;strong&gt;4. Add a scroll bar and a play button linked to the “today” cell&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Now for the magic. Add a scroll bar below the chart.&lt;br&gt;&lt;em&gt;Excel 2007 users:&lt;/em&gt; Go to Developer – Insert and add a scroll bar.&lt;br&gt;&lt;em&gt;Excel 2003 users:&lt;/em&gt; Go to View - Toolbars - Control Toolbox and add a scroll bar&lt;/p&gt; &lt;p&gt;Right click on the scroll bar, go to Format Control… and link the scroll bar to the “Offset” cell. Now, as you move the scroll bar, the value in the offset cell will change to reflect it. So the “today” cell will change too. So will the lookup table. And so will the chart.&lt;/p&gt; &lt;p&gt;Next, create a button called “Play” and edit its code.&lt;br&gt;&lt;em&gt;Excel 2007 users:&lt;/em&gt; Right click the button, go to Developer – View Code.&lt;br&gt;&lt;em&gt;Excel 2003 users:&lt;/em&gt; Right click the button and select View Code.&lt;/p&gt; &lt;p&gt;Type in the following code for the button’s click event:&lt;/p&gt;
```vb
Declare Sub Sleep Lib &#34;kernel32&#34; (ByVal dwMilliseconds As Long)
&lt;p&gt;Sub Button1_Click()
Dim i As Integer
For i = 0 To 40: &amp;rsquo; Replace 40 with your range
Range(&amp;ldquo;J1&amp;rdquo;).Value = i &amp;rsquo; Replace J1 with your offset cell
Application.Calculate
Sleep (100)
Next
End Sub&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;&amp;lt;p&amp;gt;Now clicking on the Play button will give you this glorious motion chart in Excel:&amp;lt;/p&amp;gt;
&amp;lt;p&amp;gt;&amp;lt;/p&amp;gt;&amp;lt;object classid=&amp;#34;clsid:D27CDB6E-AE6D-11cf-96B8-444553540000&amp;#34; codebase=&amp;#34;http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0&amp;#34; width=&amp;#34;451&amp;#34; height=&amp;#34;334&amp;#34; id=&amp;#34;motion-chart.swf&amp;#34;&amp;gt;
&amp;lt;param name=&amp;#34;movie&amp;#34; value=&amp;#34;/a/motion-chart.swf&amp;#34;&amp;gt;
&amp;lt;param name=&amp;#34;quality&amp;#34; value=&amp;#34;high&amp;#34;&amp;gt;
&amp;lt;param name=&amp;#34;bgcolor&amp;#34; value=&amp;#34;#ffffff&amp;#34;&amp;gt;
&amp;lt;embed src=&amp;#34;/a/motion-chart.swf&amp;#34; quality=&amp;#34;high&amp;#34; bgcolor=&amp;#34;#ffffff&amp;#34; width=&amp;#34;451&amp;#34; height=&amp;#34;334&amp;#34; name=&amp;#34;motion-chart.swf&amp;#34; type=&amp;#34;application/x-shockwave-flash&amp;#34; pluginspage=&amp;#34;http://www.macromedia.com/go/getflashplayer&amp;#34;&amp;gt;&amp;lt;/embed&amp;gt;
&amp;lt;/object&amp;gt;

---

## Comments

&amp;lt;!-- wp-comments-start --&amp;gt;
- **[Vinoth](http://vinovator.blogspot.com)** _13 Mar 2009 9:27 am_:
  Hi Anand.Very useful article.
  I can use similar motion chart to showcase how each of my team member&amp;#39;s cumulative performance is contributing at the overall level.
- **Zoheb** _21 Mar 2009 12:02 am_:
  also could you rewrite the whole code,on how to slow it down.. i tried inserting it.but i don&amp;#39;t think i put it in the right place.
- **David** _18 Mar 2009 2:16 pm_:
  Thanks! That did the trick! Great Blog!
- **David** _17 Mar 2009 7:56 pm_:
  Is there a way to slow it down?
- **[S Anand](http://www.s-anand.net/)** _17 Mar 2009 8:44 pm_:
  Sure. Use the sleep function. Add this to the module:
 \
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Declare Sub Sleep Lib &amp;ldquo;kernel32&amp;rdquo; (ByVal dwMilliseconds As Long)&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;\
Then add a Sleep function after `Application.Calculate`
\
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Sleep 200&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;- **Nach** _17 Mar 2009 8:50 am_:
Thank you...this is something that I have been trying to do for a long time now...but didnt know how to write the looped macro in Excel.
- **Zoheb** _20 Mar 2009 9:52 pm_:
Hi I had a question, if I wanted the counter by 3, how would i do that?
Thanks
-Zoheb
- **[S Anand](http://www.s-anand.net/)** _23 Mar 2009 7:39 am_:
I&amp;#39;ve changed the code and also revised it in the Excel file. Take a look.
To increment the counter by 3, change the properties of the scroll bar to make the increment 3 instead of 1. (Right click on the scroll bar and select &amp;#34;Properties&amp;#34;)
- **[Al-Hamour](http://www.alhamour.com)** _23 Mar 2009 1:50 am_:
Great post! Thanks for sharing. Time delay code is very useful if you can upload it.. right now it goes too fast to see.
Also, is there a way to make the graph trace each of the moving circles?
- **Venkat** _1 Apr 2009 3:12 pm_:
Thanks Anand. Very useful to represent often boring data like time series analysis.
- **Firman** _17 Apr 2009 3:53 am_:
Thank you so much... i hope in the near future you can give us tutorial / article about how to make it more interactive... say... after we click the bubble we can divide it into smaller / more detailed parts.
Thank you
- **Reginald Vaz** _17 Apr 2009 7:08 pm_:
Extremely useful...thanks a lot for sharing
- **Pradeep Jindal** _2 May 2009 6:57 pm_:
Fabulous! I just starting to do it and find this article...
everything redy and beautiful...
can we add drill down to it
Thank you Anand :)
- **Mike** _12 May 2009 3:43 pm_:
Great Tool. I am also looking for a way to pause the animation. Any ideas?
- **Pete** _4 Jun 2009 1:30 am_:
Is there a way to embed the animation in excel?
- **[S Anand](http://www.s-anand.net/)** _14 Jul 2009 5:25 pm_:
Don&amp;#39;t think we can export these motion charts into Powerpoint, I&amp;#39;m afraid.
- **[Sunny](http://www.iimb.ernet.in)** _13 Jul 2009 9:38 pm_:
Is there any way I can export these motion charts into microsoft powerpoint?
- **beth** _15 Jul 2009 1:50 am_:
do you know how you can embed this into a powerpoint? when i try to embed, you can&amp;#39;t do the motion.
- **Sabnish** _11 Jul 2009 11:26 am_:
Hi...great help...thanks a lot....but for my presentation i will need to see the evolution by years...in this example it is the date which gets incremented...how to increase the year instead...thanks...hope you can help me....
- **Michael Brault** _8 Dec 2009 3:11 pm_:
I have the motion chart embed into a Dashboard with other charts and tables. The macro increments all tables. Any ida on how to limit the macro to a single table of data?
- **Alex** _22 Jan 2010 10:57 pm_:
Having problems creating it in Excel for mac. Any ideas?
- **[derek](http://i-ocean.blogspot.com/)** _14 May 2010 7:17 pm_:
Another kind of motion chart can be a line or bar chart showing the evolution of multiple line shapes or histograms with time.
You can also add a time display to show when the events are occurring. Rosling&amp;#39;s application cleverly displays the year as a giant watermark behind the bubbles, so the eye doesn&amp;#39;t have to stray to a corner to see the time. I&amp;#39;ve often thought a clock face symbol might be a neat alternative to a simple text display.
- **[Jeff Koenig](http://connellcommodities.com)** _5 Feb 2010 7:33 pm_:
Great bubble chart solution. I&amp;#39;ve been looking for a 3D bubble chart so I can move bubbles in 3D space, allowing me to track an additional dimension. Any ideas?
- **Dirk Cornette** _13 Apr 2010 10:23 pm_:
Great solution Anand.
I am trying to customize it, showing 1 customer per buble, size = revenue, Y-axes = number of our staff working for that customer, X axes showing margin %.
Solving two issues would make it more gapminder-like.
1. How to add a data label to the buble, showing the customer name ?
2. How to show the year ?
Any ideas ?
- **[Mahdi Meskin](http://www.meskin.ir)** _4 Jun 2010 6:24 am_:
Great post!
thanks.
- **[Drew](http://www.totallyawesomemapping.com)** _11 May 2010 4:10 pm_:
Just found your post, and I can&amp;#39;t wait to try it out. Thanks for the tips!
- **NIall Tallon** _18 Aug 2010 12:08 pm_:
HI Anand,
This is great - a while since I updated and wrote macros - I am running a 64bit version of windows 7 and excel 2010 - and the macro won&amp;#39;t run there - any ideas?
Thanks,
Niall
- **Niall Tallon** _18 Aug 2010 12:19 pm_:
HI Again,
Actually just have to add &amp;#34;PTRsafe&amp;#34; in the macro near the declare statement.
Pretty easy.......Email me if you want a copy with the changed macro.
Best regfards and with thanks,
NT
- **Kamesh.M** _15 Sep 2010 10:00 am_:
Great Post!
This can be done without Macros also.....
http://www.webanalyticsindia.com/2009-11-20/motion-chart-in-excel/
Best Regards
Kamesh
- **Pvl** _27 Jun 2012 8:41 am_:
Hi, Anand,
Thanks for good tutorial. But I&amp;#39;m very interested in creating such motion chart in Flash, like You posted as an example. Any suggestions how to do that?
- **Scott** _20 Dec 2010 4:31 pm_:
Hi,
Is it possible to make this so the individual bubbles have different colors or at least unique labels? I can only seem to have all the bubbles be one color and one label &amp;#39;Thing&amp;#39;....
Thanks,
Scott
- **James Arnott** _8 Sep 2011 2:56 pm_:
Hi - I&amp;#39;ve come late to this but am finding it very useful. Thanks for sharing your work with us as it would have taken me ages to work it out myself.
- **Anna** _2 Nov 2011 3:52 pm_:
Does anyone know if it is possible to include this chart in a Share Point site? I know you can upload dashboards with the REST API but I don&amp;#39;t know if it is possible to add motion charts. Can you shed some light on this topic. Thanks!
- **Atisha Banjare** _11 Nov 2011 11:06 am_:
Hi!! Great stuff and really useful. Thanks
- **kalaisam** _23 Jan 2012 11:37 am_:
Hai,
I read Excel file from my Google account using Zend. I call Motion chart using Publish gadget script. It automatically assign the default X-axis and Y-axis .I wish to assign the X- axis and Y-axis . I choose Advanced settings option to change the Axis and then call that script string in Php code. But Default axis only displayed ! How can i fix that ?
- **Bill** _16 Apr 2012 5:41 pm_:
Is it possible to have bubble diameters also show thier diameter change over time? Various smoothing algorithms could be offered to choose from.
- **Nal** _23 Mar 2012 6:48 am_:
hi, this is fantastic! Is it possible to put this into my powerpoint presentation?
thanks!
- **Sreekar** _3 Sep 2011 9:19 pm_:
Hi Anand - I tried using your macro and it gives a compilation error &amp;#34;Sub or Function not defined&amp;#34;; would you know how I could fix it? I am using 2010 Excel
- **Alan** _15 Sep 2011 1:01 am_:
Can you please post me the updated version for Excel 2010.
I dont know how to update the declare statement to include &amp;#34;PTR Safe&amp;#34;
Thank you
Alan
- **Chris** _28 Mar 2012 11:08 pm_:
Wonderful! Thanks for all this work. I use Excel 2010 and it shouldn&amp;#39;t be too hard to adapt it (I won&amp;#39;t bother you about it).
It&amp;#39;s too bad it can&amp;#39;t be embedded in PPT. Microsoft definitely needs to add this kind of thing to PowerPoint.
- **Kirk** _23 Jun 2012 4:57 pm_:
I tried this macro but got an error saying the macros in this project are disabled. Anyone have an idea on what I am doing wrong?
Sub Button20\_Click()
Declare Sub Sleep Lib &amp;#34;kernel32&amp;#34; (ByVal dwMilliseconds As Long)
Sub Button1\_Click()
Dim i As Integer
For i = 0 To 40:
Range(&amp;#34;J1&amp;#34;).Value = i
Application.Calculate
Sleep (100)
Next
End Sub
- **CK** _6 May 2012 10:18 am_:
Thank you for this useful tutorial.
How did you embed the motion chart moving on your web page please?
- **Gary** _16 Jul 2012 2:37 am_:
Oh, sorry to mention that it stops at the Sleep (100). I even tried to add the Declare but for some odd reason it keep advancing above where I type it. I appreciate any help.
Thank you
- **Gary** _16 Jul 2012 2:34 am_:
First let me say thank you. The code you posted did not work for me. I am using MS Excel 2010 and I keep getting the same error.
Microsoft Visual Basic for Applications
Compile error:
Sub or Function not defined.
Can you help me fix this error. This is what I have typed.
Sub Button1\_Click()
Dim i As Integer
For i = 1 to 39:
Range (&amp;#34;C1&amp;#34;).Value = 1
Application.Calculate
Sleep (100)
Next
End Sub
- **Seymon** _15 Jul 2012 2:17 am_:
it is awesome, thanks
- **Merry Turnip** _9 Oct 2012 12:21 pm_:
THANK YOU SO MUCH, FOR YOUR TUTORIAL, I HAVE TRIED IT AND IT WORKS.
THANK YOU SO MUCH.
By the way, when I change Years to months, however, it doesn&amp;#39;t work. Could you please teach me how to change year to months?
THANK AGAIN
REGARDS
- **Mukesh** _5 Sep 2012 11:24 pm_:
Hi Anand,
I need to show the data for only 4 years.
Could you please tell me how to slow down the motion further ?
I tried increasing the value of the number in Sleep (), but its not making a difference
- **maanu** _19 Nov 2012 10:34 am_:
hi anand, i want to build a bubble chart for my applications globally with four variables, application investment strategy meaning invest, maintain or disinvest, cost, location, and functional match. i want to handle location with color as there are only 8 locations, and cost with size. i want app investment strategy as numbers (1,2 ,3) on y axis and functional match with five categories (0-20 21-40,41-60,61-80,81-100) on x axis. can we use your technique to achieve this ?
- **Obed** _18 Feb 2013 8:02 am_:
Thanks for sharing your wealth of knowledge with others. Great stuff!!!
- **Michael** _24 Feb 2013 5:31 am_:
In their infinite wisdom Google is discontinuing motion chart gadgets in 2013 so a big thank you for this alternative:-)
- **[Ganeshan Nadarajan](http://www.solidradicle.com)** _16 Jan 2013 12:27 pm_:
Motion charts are animated bubble charts. They track the performance of important things over time (in two dimensions). This is chart with 4 dimensions. But not all data with 4 dimensions can be plotted as a motion chart. One dimension has to be time, and another has to be linked to the importance of the item.
- **isspenguin** _17 Jan 2013 5:12 pm_:
Hello - How do I create &amp;#34;trails&amp;#34; that trace the path of individual bubbles in Excel, like they do in Google motion charts?﻿ Please feel free to email me your response at rdivya09@gmail.com. Thanks!
- **[Stefan Selby](https://googledrive.com/host/0B0Ms4sM4a2RoSW9YYmkxbVlMc2M/vbamotioncharts.html)** _25 Nov 2013 8:07 pm_:
It is interesting to see how you did your motion charts. I have created an app that does more than just bubble charts. I have done the same for most excel charts and a speedometer chart. It is shared with the world have a look at:https://googledrive.com/host/0B0Ms4sM4a2RoSW9YYmkxbVlMc2M/vbamotioncharts.html
- **[sireesh](http://www.ses.com)** _11 Jul 2013 10:17 pm_:
how to transfer bubble chart to ppt?
- **Mike** _26 Jul 2013 11:02 pm_:
Does the code work with 2010? Nothing happens when I copy and paste it in. When I run debug the sleep (100) highlights even after I replace the data as you indicated with my own. Granted, I&amp;#39;m new to developer stuff so I may be making a silly mistake.
- **Max** _19 Jul 2013 6:50 pm_:
Thanks for the great write up. Any ideas as to how one could add a &amp;#34;tail&amp;#34; behind the moving bubble to track the past data?
- **Diana** _9 Nov 2013 4:08 am_:
Actually.....shows how hopeless I actually am....I am in Excel 2013, not 2010!
- **Diana** _9 Nov 2013 4:05 am_:
I&amp;#39;m also asking the same question as Mike #5. I can&amp;#39;t get the code to work in 2010 and the sleep (100) highlights. As I&amp;#39;m not a programmer and really don&amp;#39;t have a clue, I&amp;#39;d love to get this handled. I&amp;#39;ve come this far and have great individual graphs!. Thanks....
- **Loveleen** _8 Apr 2014 3:57 am_:
I can’t get the code to work in 2010 and the sleep (100) highlights. As I’m not a programmer to understand the coding. COuld you please how it works in 2010
regards,
Loveleen
- **Ye** _13 Mar 2015 6:28 pm_:
Thank you so much for this workaround (I usually did this with googledocs) in excel. I am trying to make this work - not based on increasing date, but on temperature. Imagine a chemistry-based excel sheet and I want to show how different components change volume, weight and surface opaqueness with rising temperature. Right now, I struggle to make the today and offset work for me since the example is (like google docs) based on a start date.
Thanks for your reply in advance.
Y
- **Durga** _18 Jun 2014 4:11 pm_:
This was very useful for me. Thank you for describing the play button logic. On the web site when I click on the pause or the stop button the chart stops at that moment but I didn&amp;#39;t see it in the excel. Could you please tell me how to code the stop button or the pause button on excel.
- **Nathalie** _11 Jun 2014 5:06 pm_:
It is very interesting. However, there is one little problem that stops me from using this kind of chart: the size of the bubbles does not follow the variation of size values in time. For instance, if bubble A remains the biggest bubble over the time, it will keep the same size in the chart, even if its value has increased by a factor 3 one year. I would have expected the size to be 3 times bigger than in the previous year. Is there a way to remedy this (without having to use Google motion charts)?
- **[Stef](http://developingdata.azurewebsites.net/)** _30 Dec 2014 12:46 pm_:
I have created an app that creates these and other types of motion charts. You can find it at http://developingdata.azurewebsites.net/Excel/ExcelMotionCharts
Knowing excel and reading this article would help (good article) but I have tried to make the app easy to use.
- **Des Klass** _1 Jan 2015 1:01 am_:
Hi I am having the same problem as Mike(#5) and just can&amp;#39;t get the motion working. Greatful for any suggestions(I am using my own data)
- **Atom** _18 Dec 2014 8:07 am_:
How do i change the years to seconds?
- **Ryan** _14 Aug 2015 7:42 pm_:
I&amp;#39;m also having the same Sleep (100) error in 2010. Is there a work around for this?
- **[Niall](http://n/a)** _22 Mar 2016 5:07 pm_:
HI There - really love the motion chart work here - I&amp;#39;ve been using it for a while - but I recently went to O365 and the graphs I made don&amp;#39;t work anymore - any ideas?
Many thanks,
Niall
- **Rochny** _15 Feb 2019 12:24 pm_:
I can’t get the code to work in 2016 and the sleep (100) highlights.
Can get help, as i am not a programmer.
regards
Rochny
- **[JEP](http://patientflow.dk)** _3 Apr 2017 9:26 am_:
The code work with 2010 if you delete &amp;#34;sleep (100)&amp;#34; :-)
&amp;lt;!-- wp-comments-end --&amp;gt;
&lt;/code&gt;&lt;/pre&gt;</description>
    </item>
    <item>
      <title>RSS feeds in Excel</title>
      <link>https://www.s-anand.net/blog/rss-feeds-in-excel/</link>
      <pubDate>Thu, 03 May 2007 12:00:00 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/rss-feeds-in-excel/</guid>
      <description>&lt;p&gt;The technique of &lt;a href=&#34;https://www.s-anand.net/blog/web-lookup-using-excel/&#34;&gt;Web lookups in Excel&lt;/a&gt; I described yesterday is very versatile. I will be running through some of the practical uses it can be put to over the next few days&lt;/p&gt;
&lt;p&gt;TO generalise things beyond just &lt;a href=&#34;https://www.s-anand.net/blog/web-lookup-using-excel/&#34;&gt;getting the Amazon price&lt;/a&gt;, I created a &lt;a href=&#34;https://www.s-anand.net/blog/user-defined-functions-in-excel/&#34;&gt;user-defined function&lt;/a&gt; called XPATH. It takes two parameters:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;URL&lt;/strong&gt; of the XML feed to read&lt;br&gt;
&lt;strong&gt;Search&lt;/strong&gt; XPath list string (separated by spaces)&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;This function can be used to extract information out of any XML file on the Web and get it out as a table. For example, if you wanted to watch the Top 10 movies on the &lt;a href=&#34;http://www.imdb.com/chart/top&#34;&gt;IMDb Top 250&lt;/a&gt;, and were looking for torrents, an RSS feed is available from &lt;a href=&#34;http://www.mininova.org/&#34;&gt;mininova&lt;/a&gt;. The URL &lt;a href=&#34;http://www.mininova.org/rss/movie&#34;&gt;http://www.mininova.org/rss/movie&lt;/a&gt;_name/4 gives you an RSS file matching all movies with &amp;ldquo;movie_name&amp;rdquo;. From this, we need to extract the &lt;item&gt;&lt;title&gt; and &lt;item&gt;&lt;link&gt; elements. That&amp;rsquo;s represented by &amp;ldquo;//item title link&amp;rdquo; on my search string.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://www.s-anand.net/blog/assets/flickr-mininova-rss-feed-in-excel_482789516_o-png.webp&#34;&gt;&lt;img alt=&#34;Mininova RSS feed in Excel&#34; loading=&#34;lazy&#34; src=&#34;https://www.s-anand.net/blog/assets/flickr-mininova-rss-feed-in-excel_482789516_o-png.webp&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The formula becomes &lt;code&gt;XPath2( &amp;quot;http://www.mininova.org/rss/&amp;quot;&amp;amp;A2&amp;amp;&amp;quot;/4&amp;quot;, &amp;quot;//item title link&amp;quot;)&lt;/code&gt;. The result is a 2-dimensional array returning individual items in rows, and the columns are title and link. Pulling it all together, you can get the sheet above.&lt;/p&gt;
&lt;p&gt;All of this could be done using a command-line program. Excel has one huge advantage though. It&amp;rsquo;s one of the most powerful user-interfaces. Increasingly, I&amp;rsquo;m beginning to rely on just two user interfaces for almost any task. One is the browser, and the other is Excel. With Excel, I could have a sheet that has my &lt;a href=&#34;https://www.s-anand.net/blog/wishlist-for-movies/&#34;&gt;movie wishlist&lt;/a&gt; (which changes often), and add check to see if the torrent exists. Every time I add a bunch of movies to the wishlist, it&amp;rsquo;s just a matter of copying the formula down. No need to visit a torrent search engine and typing each movie in, one by one.&lt;/p&gt;
&lt;p&gt;Another example. Someone suggests 10 movies to watch. I&amp;rsquo;d rather watch the ones with a higher IMDb rating. Again, enter the Web lookup. Type in the movie names. Use a function like this to look up the rating on IMDb, and sort by the rating.&lt;/p&gt;
&lt;p&gt;The possibilities are endless.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&#34;comments&#34;&gt;Comments&lt;/h2&gt;
&lt;!-- wp-comments-start --&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Isit?&lt;/strong&gt; &lt;em&gt;3 May 2007 12:00 pm&lt;/em&gt;:
Is it possible to have the feeds update cumulative so the old feeds dont get replaced in excel?&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Alex&lt;/strong&gt; &lt;em&gt;3 May 2007 12:00 pm&lt;/em&gt;:
Hi, I have an Excel spreadsheet with URLs of move titles on IMDB, and I would like to retrieve the movie rating. I&amp;rsquo;ve read your tutorials, and this one comes closest to what I need. However I still cannot figure out what needs to be done. It looks like you have this problem solved. If so, can you possibly share your solution with me? Thank you, Alex&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Kishan&lt;/strong&gt; &lt;em&gt;3 May 2007 12:00 pm&lt;/em&gt;:
I came here searching for the other way round. That is to publish an RSS feed of what I have in Xcel! Thanks Anyways&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;venkat&lt;/strong&gt; &lt;em&gt;15 Oct 2010 4:09 pm&lt;/em&gt;:
Anand
Can you provide the xpath function?, I need to read a rss feed into excel, and i want only some columns of data, i would appreciate if you could send the xpath function to my email id
Thanks
venkat&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;&lt;a href=&#34;http://www.light-sensors.com&#34;&gt;Light Sensors&lt;/a&gt;&lt;/strong&gt; &lt;em&gt;2 Dec 2010 7:08 pm&lt;/em&gt;:
movie ratings really depend on how cool the movie is, i usually rate movies depending on the story line `-;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;rt&lt;/strong&gt; &lt;em&gt;27 Jun 2013 5:41 pm&lt;/em&gt;:
Hi, nice job ! can you share with me your xpath2 (i tried your other one without succes on amazon) ?Thanks, R&lt;/li&gt;
&lt;/ul&gt;
&lt;!-- wp-comments-end --&gt;
</description>
    </item>
    <item>
      <title>Web lookup using Excel</title>
      <link>https://www.s-anand.net/blog/web-lookup-using-excel/</link>
      <pubDate>Thu, 03 May 2007 12:00:00 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/web-lookup-using-excel/</guid>
      <description>&lt;p&gt;Take a look at the Excel screenshot below.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://www.s-anand.net/blog/assets/flickr-amazon-web-prices_481952444_o-png.webp&#34;&gt;&lt;img alt=&#34;Amazon Web Prices&#34; loading=&#34;lazy&#34; src=&#34;https://www.s-anand.net/blog/assets/flickr-amazon-web-prices_481952444_o-png.webp&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Yes, that&amp;rsquo;s right. I have a &lt;a href=&#34;https://www.s-anand.net/blog/user-defined-functions-in-excel/&#34;&gt;user-defined function&lt;/a&gt; called AMAZONPRICE. And it returns these cameras&amp;rsquo; &lt;strong&gt;prices directly from Amazon.com&lt;/strong&gt;. (Given the category and some keywords, it returns the price of the bestselling item on Amazon.com.)&lt;/p&gt;
&lt;p&gt;Here&amp;rsquo;s the code behind the function.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-javascript&#34; data-lang=&#34;javascript&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nb&#34;&gt;Function&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;AmazonPrice&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;index&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;As&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;keywords&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;As&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;String&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;As&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;String&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;nx&#34;&gt;Dim&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;xDoc&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;As&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;MSXML2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;DOMDocument30&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;nx&#34;&gt;Set&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;xDoc&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;New&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;MSXML2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;DOMDocument30&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;nx&#34;&gt;xDoc&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;kr&#34;&gt;async&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;False&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;nx&#34;&gt;If&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;xDoc&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;Load&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;http://ecs.amazonaws.com/onca/xml?Service=AWSECommerceService&amp;#34;&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;_&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;s2&#34;&gt;&amp;#34;&amp;amp;Version=2005-03-23&amp;amp;Operation=ItemSearch&amp;amp;SubscriptionId=03SDGQDFEB455W53SB82&amp;#34;&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;_&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;s2&#34;&gt;&amp;#34;&amp;amp;AssociateTag=sanand-20&amp;amp;MinimumPrice=10000&amp;amp;ResponseGroup=OfferSummary,Small&amp;#34;&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;_&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;s2&#34;&gt;&amp;#34;&amp;amp;Sort=salesrank&amp;amp;SearchIndex=&amp;#34;&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;index&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;&amp;amp;Keywords=&amp;#34;&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;&amp;amp;&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;keywords&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;Then&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nx&#34;&gt;xDoc&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;setProperty&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;SelectionLanguage&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;XPath&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nx&#34;&gt;xDoc&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;setProperty&lt;/span&gt; &lt;span class=&#34;s2&#34;&gt;&amp;#34;SelectionNamespaces&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;_&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;      &lt;span class=&#34;s2&#34;&gt;&amp;#34;xmlns:a=&amp;#34;&amp;#34;http://webservices.amazon.com/AWSECommerceService/2005-03-23&amp;#34;&amp;#34;&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    &lt;span class=&#34;nx&#34;&gt;AmazonPrice&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;xDoc&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;selectSingleNode&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s2&#34;&gt;&amp;#34;/a:ItemSearchResponse//a:Amount&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;).&lt;/span&gt;&lt;span class=&#34;nx&#34;&gt;Text&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;  &lt;span class=&#34;nx&#34;&gt;End&lt;/span&gt; &lt;span class=&#34;nx&#34;&gt;If&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nx&#34;&gt;End&lt;/span&gt; &lt;span class=&#34;nb&#34;&gt;Function&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;hr&gt;
&lt;p&gt;This is how it all started&amp;hellip;&lt;/p&gt;
&lt;p&gt;Flickr has a &lt;a href=&#34;http://www.flickr.com/cameras/&#34;&gt;camera finder&lt;/a&gt; that shows the most popular cameras in the Flickr community.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://www.s-anand.net/blog/assets/flickr-flickr-camera-finder_481952446_o-png.webp&#34;&gt;&lt;img alt=&#34;flickr Camera Finder&#34; loading=&#34;lazy&#34; src=&#34;https://www.s-anand.net/blog/assets/flickr-flickr-camera-finder_481952446_o-png.webp&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I &lt;a href=&#34;https://www.s-anand.net/blog/how-i-buy-gadgets/&#34;&gt;love comparing gadgets&lt;/a&gt;, I&amp;rsquo;d been doing some research around these cameras, and the &lt;a href=&#34;http://www.flickr.com/cameras/fujifilm/&#34;&gt;Fuji series&lt;/a&gt; (because I own a &lt;a href=&#34;https://www.s-anand.net/blog/my-fuji-finepix-s5600/&#34;&gt;Fuji Finepix S5600&lt;/a&gt;). I&amp;rsquo;d normally make a spreadsheet that compares these cameras on various parameters, including price.&lt;/p&gt;
&lt;p&gt;Since I believe in &lt;a href=&#34;https://www.s-anand.net/blog/excel-never-type-in-data/&#34;&gt;never typing in data&lt;/a&gt;, wondered if there was a way to get the prices in automatically&amp;hellip;&lt;/p&gt;
&lt;p&gt;Two things made this possible.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Amazon offers &lt;a href=&#34;http://www.amazon.com/gp/browse.html?node=3435361&#34;&gt;web services&lt;/a&gt; which let you get price (and almost any other) data for their products&lt;/li&gt;
&lt;li&gt;Visual Basic lets you use pretty much any ActiveX object as a control. Microsoft offers &lt;a href=&#34;http://msdn2.microsoft.com/en-us/xml/bb291077.aspx&#34;&gt;MSXML&lt;/a&gt; which you can use to load (or download) any XML file, and parse it.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;The first task is to get the XML feed for a product you want. Amazon lets you do that through by typing in a URL. The best way to construct the URL is through &lt;a href=&#34;http://www.awszone.com/&#34;&gt;AWSZone&lt;/a&gt;. I picked the &lt;a href=&#34;http://www.awszone.com/scratchpads/aws/ecs.us/ItemSearch.aws&#34;&gt;US ItemSearch&lt;/a&gt; method, which searches for a title or keyword within a category, and returns the matches. The feed for the Canon EOS Digital Rebel XT, based on this, would be at:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-text&#34; data-lang=&#34;text&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;http://ecs.amazonaws.com/onca/xml?
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    Service=AWSECommerceService&amp;amp;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    Version=2005-03-23&amp;amp;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    Operation=ItemSearch&amp;amp;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    SubscriptionId=0525E2PQ81DD7ZTWTK82&amp;amp;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    SearchIndex=Electronics&amp;amp;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    Keywords=Canon EOS Digital Rebel XT&amp;amp;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    Sort=salesrank&amp;amp;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;    ResponseGroup=Offers,Small
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;(You really need to replace the Subscription ID with your own.)&lt;/p&gt;
&lt;p&gt;If you &lt;a href=&#34;http://ecs.amazonaws.com/onca/xml?Service=AWSECommerceService&amp;amp;Version=2005-03-23&amp;amp;Operation=ItemSearch&amp;amp;SubscriptionId=0525E2PQ81DD7ZTWTK82&amp;amp;SearchIndex=Electronics&amp;amp;Keywords=Canon%20EOS%20Digital%20Rebel%20XT&amp;amp;Sort=salesrank&amp;amp;ResponseGroup=Offers,Small&#34;&gt;retrieved this URL&lt;/a&gt;, you have an XML file containing the details of all Canon EOS Digital Rebel XTs, sorted by sales rank.&lt;/p&gt;
&lt;p&gt;To load this in Excel, you need to create a &lt;a href=&#34;https://www.s-anand.net/blog/user-defined-functions-in-excel/&#34;&gt;UDF&lt;/a&gt; in Visual Basic. First, go to &lt;strong&gt;Tools - References and enable Microsoft XML, v3.0 or v4.0&lt;/strong&gt;. Now, to load an XML document, do this:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-vb&#34; data-lang=&#34;vb&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;Dim&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;xDoc&lt;/span&gt; &lt;span class=&#34;ow&#34;&gt;As&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;MSXML2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;DOMDocument30&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;k&#34;&gt;Set&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;xDoc&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;New&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;MSXML2&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;DOMDocument30&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;xDoc&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;async&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;k&#34;&gt;False&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;xDoc&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Load&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;url&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If the load succeeds, then you can extract the information fairly easily, using &lt;a href=&#34;http://www.w3.org/TR/xpath&#34;&gt;XPath&lt;/a&gt;.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-vb&#34; data-lang=&#34;vb&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;xDoc&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;setProperty&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;&amp;#34;SelectionLanguage&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;&amp;#34;XPath&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;xDoc&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;setProperty&lt;/span&gt; &lt;span class=&#34;s&#34;&gt;&amp;#34;SelectionNamespaces&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;,&lt;/span&gt; _
&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;        &lt;span class=&#34;s&#34;&gt;&amp;#34;xmlns:a=&amp;#34;&amp;#34;http://webservices.amazon.com/AWSECommerceService/2005-03-23&amp;#34;&amp;#34;&amp;#34;&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;The first line says we&amp;rsquo;ll be searching using XPath. The second line is a &lt;a href=&#34;http://support.microsoft.com/kb/313372&#34;&gt;workaround to support default namespaces&lt;/a&gt;. (Don&amp;rsquo;t worry about it. I don&amp;rsquo;t quite get it either.)&lt;/p&gt;
&lt;p&gt;Finally, you get the price from the XML tree. In this case, it&amp;rsquo;s under ItemSearchResponse/Items/Item/OfferSummary/LowestNewPrice/Amount, and it&amp;rsquo;s in cents.&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-vb&#34; data-lang=&#34;vb&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;n&#34;&gt;AmazonPrice&lt;/span&gt; &lt;span class=&#34;o&#34;&gt;=&lt;/span&gt; &lt;span class=&#34;n&#34;&gt;xDoc&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;.&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;selectSingleNode&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;(&lt;/span&gt;&lt;span class=&#34;s&#34;&gt;&amp;#34;/a:ItemSearchResponse//a:Amount&amp;#34;&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;).&lt;/span&gt;&lt;span class=&#34;n&#34;&gt;Text&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;That&amp;rsquo;s it! Now that this function is defined, just pass it the category and keywords, and you have the price of the first matching product. You can retrieve any other information about products as well &amp;ndash; like sales rank, weight, ratings, reviews, etc.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;Here&amp;rsquo;s the &lt;a href=&#34;https://files.s-anand.net/blog/a/AmazonPrices.xls&#34;&gt;spreadsheet&lt;/a&gt; for you to play around with.&lt;/p&gt;
&lt;hr&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&#34;http://www.amazon.com/gp/product/0764540726&#34;&gt;Excel 2003 Power Programming with VBA (Excel Power Programming With Vba&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&#34;http://www.amazon.com/gp/product/0596003595&#34;&gt;Writing Excel Macros with VBA, 2nd Edition&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;hr&gt;
&lt;h2 id=&#34;comments&#34;&gt;Comments&lt;/h2&gt;
&lt;!-- wp-comments-start --&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Saurabh&lt;/strong&gt; &lt;em&gt;3 May 2007 7:38 am&lt;/em&gt;:
There is a simpler way as well. Use Data-&amp;gt;Import External Data-&amp;gt;New Web Query. While this is not as powerful as the user defined function that you have created, but definitely a good starting point for lesser geeks :) I use this, for example, to have a dashboard kind of view for the status of the multiple projects that I handle at my work. We rely heavily on Microsoft Sharepoint at work, and using the Web Query option, I can easily get a snapshot of the status of various projects. Same can also fetch shareprices from various websites.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;S Anand&lt;/strong&gt; &lt;em&gt;3 May 2007 8:16 am&lt;/em&gt;:
Good point, Saurabh! Web Query does make getting stuff out of HTML very easy. My function operates in a different domain, though. It can access XML, which Web Query won&amp;rsquo;t, but can&amp;rsquo;t access HTML, which Web Query does. I&amp;rsquo;m planning a few more posts on how to extend this concept&amp;hellip; that will explain what I mean.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;rick sherrin&lt;/strong&gt; &lt;em&gt;3 May 2007 12:00 pm&lt;/em&gt;:
Hi, I work at a public library, in the acquisitions department. The majority of the work is manually keying in order information (that is available electronically elsewhere). I read your article about using Excel to retrieve amazon information. This is something that would be very useful to our library and would make my job easier. I have a little excel knowledge, but I have no experience with visual basic or xml, etc. So although it looks straightforward, it is still out of my reach. I would like to be able to enter a column of ISBN numbers in one column, and retrieve title, author, publisher, price, reviews, synopsis, cover image, in adjacent columns. I would appreciate your help if you would give me an example of how I could easily do this. Thanks Rick&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;dat&lt;/strong&gt; &lt;em&gt;12 Aug 2008 8:10 am&lt;/em&gt;:
useful article!
Btw, how do I retrieve other info from amazon (published date, sales rank, customer review, etc)???
thanks&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;S Anand&lt;/strong&gt; &lt;em&gt;13 Aug 2008 2:15 am&lt;/em&gt;:
@dat: Have a look at &lt;a href=&#34;http://www.awszone.com/&#34;&gt;http://www.awszone.com/&lt;/a&gt; for examples on other parameters.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Lydia&lt;/strong&gt; &lt;em&gt;3 May 2010 12:05 am&lt;/em&gt;:
this worked until august last year when amazon changed the way the query signs into their system&amp;hellip;it now requires a signature with a timestamp in addition to the subscription ID&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Bobby Baker&lt;/strong&gt; &lt;em&gt;10 Feb 2015 7:09 am&lt;/em&gt;:
Have you updated the search functions for this or do you have a new code for this?&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Vlad&lt;/strong&gt; &lt;em&gt;26 Aug 2015 10:00 pm&lt;/em&gt;:
Hey Annand
is it possible o get the racking status fro fedex for a column of tracking numbers?&lt;/li&gt;
&lt;/ul&gt;
&lt;!-- wp-comments-end --&gt;
</description>
    </item>
    <item>
      <title>User defined array functions in Excel</title>
      <link>https://www.s-anand.net/blog/user-defined-array-functions-in-excel/</link>
      <pubDate>Fri, 23 Feb 2007 12:00:00 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/user-defined-array-functions-in-excel/</guid>
      <description>&lt;p&gt;Many languages have functions to process lists (array). These functions usually return a list, so you can pass that to another list function. This chaining of functions is really powerful.&lt;/p&gt;
&lt;p&gt;UNIX provides this sort of chaining capability. If I had a cities (with some repetitions) and I wanted to find out how many started with the letter &amp;lsquo;A&amp;rsquo;, I&amp;rsquo;d just type:&lt;/p&gt;
&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-bash&#34; data-lang=&#34;bash&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;cat cities &lt;span class=&#34;p&#34;&gt;|&lt;/span&gt; sort &lt;span class=&#34;p&#34;&gt;|&lt;/span&gt; uniq &lt;span class=&#34;p&#34;&gt;|&lt;/span&gt; grep &lt;span class=&#34;s2&#34;&gt;&amp;#34;^A&amp;#34;&lt;/span&gt; &lt;span class=&#34;p&#34;&gt;|&lt;/span&gt; wc
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class=&#34;highlight&#34;&gt;&lt;pre tabindex=&#34;0&#34; class=&#34;chroma&#34;&gt;&lt;code class=&#34;language-yaml&#34; data-lang=&#34;yaml&#34;&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nt&#34;&gt;cat&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;types the cities.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nt&#34;&gt;sort&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;sorts the cities alphabetically.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nt&#34;&gt;uniq&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;finds unique cities (works only if sorted - that&amp;#39;s why we had to sort the list).&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nt&#34;&gt;grep&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;filters the cities. Only allows cities beginning with A.&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&#34;line&#34;&gt;&lt;span class=&#34;cl&#34;&gt;&lt;span class=&#34;nt&#34;&gt;wc&lt;/span&gt;&lt;span class=&#34;p&#34;&gt;:&lt;/span&gt;&lt;span class=&#34;w&#34;&gt; &lt;/span&gt;&lt;span class=&#34;l&#34;&gt;word count&lt;/span&gt;&lt;span class=&#34;w&#34;&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;To do this on Excel, the only way is to&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;get the unique values&lt;/strong&gt;. Data - Filter - Advanced Filter, and select &amp;ldquo;Unique records only&amp;rdquo;, &amp;ldquo;Copy the list to another location&amp;rdquo;, and select a location&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;get the first letter&lt;/strong&gt;. =LEFT(cell,1) returns the first letter of the cell.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;count the number of &amp;ldquo;A&amp;quot;s&lt;/strong&gt;. =COUNT(range, &amp;ldquo;A&amp;rdquo;) counts the number of &amp;ldquo;A&amp;quot;s.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;But ideally, I&amp;rsquo;d like a 1-line formula like&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code class=&#34;language-excel&#34; data-lang=&#34;excel&#34;&gt;=LENGTH(UNIQUE(GREP(&amp;#34;^A&amp;#34;, range)))
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;Excel doesn&amp;rsquo;t provide these functions by default, but you can add them as &lt;a href=&#34;https://www.s-anand.net/blog/user-defined-functions-in-excel/&#34;&gt;user defined functions&lt;/a&gt;. Doing this &lt;strong&gt;lets you condense several cells into one&lt;/strong&gt;. Instead of having to copy all your data into a set of unique values, and then adding a column for the first cell, the entire operation can be condensed into one formula.&lt;/p&gt;
&lt;p&gt;I consider the following functions the a basic set for list processing.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;LENGTH(list) counts the number of elements in a list&lt;/li&gt;
&lt;li&gt;INDEX(list, n) returns the nth element of the list&lt;/li&gt;
&lt;li&gt;GREP(string, list) returns elements of the list that have the string&lt;/li&gt;
&lt;li&gt;UNIQUE(list) filters unique values&lt;/li&gt;
&lt;li&gt;UNION(list, list) returns elements in at least one of the lists&lt;/li&gt;
&lt;li&gt;INTERSECTION(list, list) returns elements in both lists&lt;/li&gt;
&lt;li&gt;DIFFERENCE(list, list) returns the elements in the first list but not the second&lt;/li&gt;
&lt;li&gt;REVERSE(list) reverses the order of the list&lt;/li&gt;
&lt;li&gt;STRJOIN(separator, list) joins the elements of the list into a string, separated by a separator&lt;/li&gt;
&lt;li&gt;STRSPLIT(separator, string) splits the string into a list, using a separator&lt;/li&gt;
&lt;li&gt;MVLOOKUP(value, lookup, result) looks up value in &amp;ldquo;lookup&amp;rdquo;, and returns the corresponding MULTIPLE values from &amp;ldquo;result&amp;rdquo;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;I created these UDFs. You can &lt;a href=&#34;https://files.s-anand.net/blog/a/Macros.xls&#34;&gt;download the functions&lt;/a&gt; and play with them. Below are some tasks that you can do with them, that are difficult otherwise.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Get the file name from a path.
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code class=&#34;language-excel&#34; data-lang=&#34;excel&#34;&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;=INDEX(REVERSE(STRSPLIT(&amp;rdquo;&amp;quot;, filename)), 1)&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;- Count the number of unique elements in a range.
  ```excel
=LENGTH(UNIQUE(range))
&lt;/code&gt;&lt;/pre&gt;&lt;ul&gt;
&lt;li&gt;How many common elements are there in range 1 and range 2?
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code class=&#34;language-excel&#34; data-lang=&#34;excel&#34;&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;=LENGTH(INTERSECTION(range1, range2))&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;- How many words are there in a string?
  ```excel
=LENGTH(STRSPLIT(&amp;#34; &amp;#34;, string))
&lt;/code&gt;&lt;/pre&gt;&lt;ul&gt;
&lt;li&gt;Get the smallest unique numbers in a range
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code class=&#34;language-excel&#34; data-lang=&#34;excel&#34;&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;=SMALL(UNIQUE(range), 5)&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;- Count the number of mismatches between two lists.
  ```excel
=COUNT(Range1)+COUNT(Range2) - COUNT(INTERSECTION(Range1,Range2))
&lt;/code&gt;&lt;/pre&gt;&lt;ul&gt;
&lt;li&gt;Get a list of mismatches between two lists.
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code class=&#34;language-excel&#34; data-lang=&#34;excel&#34;&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;=STRJOIN(&amp;rdquo;,&amp;quot;,UNION(DIFFERENCE(Range1,Range2), DIFFERENCE(Range2,Range1)))&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;- Count duplicate entries in a range.
  ```excel
=LENGTH(Range)-LENGTH(UNIQUE(Range))
&lt;/code&gt;&lt;/pre&gt;&lt;ul&gt;
&lt;li&gt;VLOOKUP multiple values
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code class=&#34;language-excel&#34; data-lang=&#34;excel&#34;&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;=MVLOOKUP(A1,Lookup_Range,Return_Range)&lt;/p&gt;
&lt;pre tabindex=&#34;0&#34;&gt;&lt;code&gt;- Count the unique matches in a VLOOKUP
  ```excel
=COUNT(UNIQUE(MVLOOKUP(A1,Lookup_Range,Return_Range)
&lt;/code&gt;&lt;/pre&gt;&lt;p&gt;This is a small sample. The power of list processing is phenomenal, especially when combined with array formulas. &lt;a href=&#34;https://files.s-anand.net/blog/a/Macros.xls&#34;&gt;Download these macros&lt;/a&gt; and play with them!&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&#34;comments&#34;&gt;Comments&lt;/h2&gt;
&lt;!-- wp-comments-start --&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Krishna&lt;/strong&gt; &lt;em&gt;24 Feb 2007 4:10 am&lt;/em&gt;:
Anand, thanks for an extremely useful stuff.In connection to our discussion on enhancing my excel skills, i think it would help me largely. Krishna&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Sundar&lt;/strong&gt; &lt;em&gt;26 Feb 2007 4:06 am&lt;/em&gt;:
Very neat job Anand. Congrats for a super job. Waht is your e-mail address? Thanx in advance&amp;hellip;&amp;hellip;&amp;hellip;&amp;hellip;S.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Anand Srini&lt;/strong&gt; &lt;em&gt;26 Feb 2007 9:40 pm&lt;/em&gt;:
Hi I reproduce this extract from your article &amp;ldquo;Instead of having to copy all your data into a set of unique values, and then adding a column for the first cell, the entire operation can be condensed into one formula&amp;rdquo; can you explain why a column has to be added for the first cell ?&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;ashwin&lt;/strong&gt; &lt;em&gt;27 Feb 2007 4:41 pm&lt;/em&gt;:
Dear Anand, As usual; another useful post from you. Thanks, Ashwin&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Kabir&lt;/strong&gt; &lt;em&gt;5 Mar 2007 9:01 pm&lt;/em&gt;:
you truly are a genius&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Shiva&lt;/strong&gt; &lt;em&gt;6 Mar 2007 2:03 pm&lt;/em&gt;:
Your site is turning to a Dexters Laboratory&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Ramly&lt;/strong&gt; &lt;em&gt;19 Mar 2007 4:35 pm&lt;/em&gt;:
Thank you very much this will help a lot&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Mansi&lt;/strong&gt; &lt;em&gt;11 Apr 2007 4:22 am&lt;/em&gt;:
Hi, was just randomly searching for how to generate unique values on excel.. and came across your website. Must say, truly impressive work and this has helped me a lot! Thank you and keep up the good work! :)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;James&lt;/strong&gt; &lt;em&gt;23 Feb 2007 12:00 pm&lt;/em&gt;:
Cheers, a lot of great stuff here, makes my Excel work much easier. My hat off to you!&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Pete Watkins&lt;/strong&gt; &lt;em&gt;23 Feb 2007 12:00 pm&lt;/em&gt;:
Thanks ever so much for your work in developing these functions, as these have allowed me to avoid a huge amount of drudgery in processing data!&lt;/li&gt;
&lt;/ul&gt;
&lt;!-- wp-comments-end --&gt;
</description>
    </item>
    <item>
      <title>User-defined functions to get cell formatting</title>
      <link>https://www.s-anand.net/blog/user-defined-functions-to-get-cell-formatting/</link>
      <pubDate>Sat, 02 Sep 2006 12:00:00 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/user-defined-functions-to-get-cell-formatting/</guid>
      <description>&lt;p&gt;Sometimes you want to check the colour of a cell, or whether a cell is bold. This can be easily done with user-defined functions (UDFs). (To create a UDF, press Alt-F11, Alt-I-M, and type the code below.)&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://www.s-anand.net/blog/assets/flickr-user-defined-functions-to-get-the-background-colour-and-bold-value-of-a-cell_231663146_o-gif.webp&#34;&gt;&lt;img alt=&#34;User defined functions to get the background colour and bold value of a cell&#34; loading=&#34;lazy&#34; src=&#34;https://www.s-anand.net/blog/assets/flickr-user-defined-functions-to-get-the-background-colour-and-bold-value-of-a-cell_231663146_o-gif.webp&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;You can use ISBOLD(cell) to check if a cell is bold, and BGCOLOR(cell) to get the background colour of the cell. This lets you selectively process bold or shaded cells. The two examples below show how you can add only the cells in bold, or only the shaded cells.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://www.s-anand.net/blog/assets/flickr-example-to-selectively-add-shaded-cells_231663147_o-gif.webp&#34;&gt;&lt;img alt=&#34;Example to selectively add shaded cells&#34; loading=&#34;lazy&#34; src=&#34;https://www.s-anand.net/blog/assets/flickr-example-to-selectively-add-shaded-cells_231663147_o-gif.webp&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://www.s-anand.net/blog/assets/flickr-example-to-selectively-add-bold-cells_231663148_o-gif.webp&#34;&gt;&lt;img alt=&#34;Example to selectively add bold cells&#34; loading=&#34;lazy&#34; src=&#34;https://www.s-anand.net/blog/assets/flickr-example-to-selectively-add-bold-cells_231663148_o-gif.webp&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Rather than use an additional column for ISBOLD or BGCOLOR, you can use an array formula, like below. (Remember to press &lt;strong&gt;Ctrl-Shift-Enter&lt;/strong&gt; instead of Enter after typing this formula)&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://www.s-anand.net/blog/assets/flickr-example-to-selectively-add-bold-cells-using-a-single-array-formula_231663149_o-gif.webp&#34;&gt;&lt;img alt=&#34;Example to selectively add bold cells using a single array formula&#34; loading=&#34;lazy&#34; src=&#34;https://www.s-anand.net/blog/assets/flickr-example-to-selectively-add-bold-cells-using-a-single-array-formula_231663149_o-gif.webp&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;But first, you need to change the &lt;a href=&#34;http://www.google.com/search?&amp;amp;q=excel+user+defined+function+%22return+an+array%22&#34;&gt;UDF to return an array&lt;/a&gt; rather than a single value. So IsBold will have to be modified as shown.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://www.s-anand.net/blog/assets/flickr-user-defined-function-isbold-modified-to-return-an-array_231669052_o-gif.webp&#34;&gt;&lt;img alt=&#34;User defined function isBold modified to return an array&#34; loading=&#34;lazy&#34; src=&#34;https://www.s-anand.net/blog/assets/flickr-user-defined-function-isbold-modified-to-return-an-array_231669052_o-gif.webp&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;User-defined functions that process arrays can be very powerful. It can bring the full power of functional programming into Excel. I&amp;rsquo;ll describe some next week.&lt;/p&gt;
&lt;p&gt;PS: In case you&amp;rsquo;re wondering, &lt;code&gt;Application.Volatile&lt;/code&gt; tells Excel to recalculate the function every time the worksheet is recalculated. When a cell is made bold, or shaded, the &lt;strong&gt;value&lt;/strong&gt; of the cell doesn&amp;rsquo;t change. So Excel doesn&amp;rsquo;t recalculate any formulas. You&amp;rsquo;ll have to manually press F9 every time to recalculate these cells. And &lt;code&gt;Application.Volatile&lt;/code&gt; ensures that when you press F9, these functions are recalculated.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&#34;comments&#34;&gt;Comments&lt;/h2&gt;
&lt;!-- wp-comments-start --&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Ramly&lt;/strong&gt; &lt;em&gt;19 Mar 2007 3:07 pm&lt;/em&gt;:
good&amp;hellip; May i ask your help to give me a solution for my problem&amp;hellip; I always use vlookup to find some data in a specific range, my lookup value are employee code number then look for there name, age, address and so on. but today, i want look up a value with multiple returns. i want to have the some of a worker which he have in a specific date. Please give help regarding this matter.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Prasath&lt;/strong&gt; &lt;em&gt;13 Nov 2009 10:00 am&lt;/em&gt;:
Hi Need a help
The ISBOLD function which is defined on top does not work if I change the cell which is Bold to Unbold.
The formula should work automatically if a cell is changed BOLD or UNBOLD&lt;/li&gt;
&lt;/ul&gt;
&lt;!-- wp-comments-end --&gt;
</description>
    </item>
    <item>
      <title>User-defined functions in Excel</title>
      <link>https://www.s-anand.net/blog/user-defined-functions-in-excel/</link>
      <pubDate>Fri, 01 Sep 2006 12:00:00 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/user-defined-functions-in-excel/</guid>
      <description>&lt;p&gt;Excel lets you create your own functions. If you wanted to create a function that returned the distance between two points (x1,y1) and (x2,y2), you can create a function DIST that takes these 4 parameters, and use it as shown below.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://www.s-anand.net/blog/assets/flickr-example-of-a-user-defined-function-in-excel_231273003_o-gif.webp&#34;&gt;&lt;img alt=&#34;Example of a user-defined function in Excel&#34; loading=&#34;lazy&#34; src=&#34;https://www.s-anand.net/blog/assets/flickr-example-of-a-user-defined-function-in-excel_231273003_o-gif.webp&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;To create such a function,&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;press Alt-F11 to open the Visual Basic Editor&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;insert a new module (Alt-I-M)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;type the following code:&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://www.s-anand.net/blog/assets/flickr-visual-basic-code-for-the-dist-user-defined-excel-function_231278952_o-gif.webp&#34;&gt;&lt;img alt=&#34;Visual Basic code for the DIST user-defined Excel function&#34; loading=&#34;lazy&#34; src=&#34;https://www.s-anand.net/blog/assets/flickr-visual-basic-code-for-the-dist-user-defined-excel-function_231278952_o-gif.webp&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Anything you declare as a &amp;ldquo;Function&amp;rdquo; in Excel&amp;rsquo;s Visual Basic automatically becomes visible in the Insert-Function dialog box under the category &amp;ldquo;User Defined&amp;rdquo; (see &lt;a href=&#34;http://www.dailydoseofexcel.com/archives/category/vba/user-defined-functions/&#34;&gt;examples&lt;/a&gt;). The function is normally saved with the file. This is a good idea if you&amp;rsquo;re going to distribute the file. You can also save your functions in your &lt;a href=&#34;http://www.google.com/search?q=personal.xls&amp;amp;btnI=I&#39;m+Feeling+Lucky&#34;&gt;personal.xls&lt;/a&gt; file and load it on startup.&lt;/p&gt;
&lt;p&gt;There are 3 places where I suggest using UDFs.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;You need to repeat a formula or use an additional cell to get the job done (e.g. replace Excel errors with empty strings)&lt;/li&gt;
&lt;li&gt;You &lt;a href=&#34;https://www.s-anand.net/blog/user-defined-functions-to-get-cell-formatting/&#34;&gt;can&amp;rsquo;t get the information&lt;/a&gt; from a formula (e.g. a cell&amp;rsquo;s background colour)&lt;/li&gt;
&lt;li&gt;It&amp;rsquo;s very cumbersome to get the information using formulas (e.g. regular expressions)&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Let&amp;rsquo;s take the first one: &lt;strong&gt;replace Excel errors with empty strings&lt;/strong&gt;. Normally, you&amp;rsquo;d store the results in a cell (say A2), and have another cell with the formula =IF(ISERROR(A2),&amp;quot;&amp;quot;,A2). Instead, create this function NOERROR:&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://www.s-anand.net/blog/assets/flickr-function-noerror-in-excel-visual-basic_231297813_o-gif.webp&#34;&gt;&lt;img alt=&#34;Function NOERROR in Excel Visual Basic&#34; loading=&#34;lazy&#34; src=&#34;https://www.s-anand.net/blog/assets/flickr-function-noerror-in-excel-visual-basic_231297813_o-gif.webp&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Now you can enclose any Excel function inside a NOERROR() and it&amp;rsquo;ll filter out the errors.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://www.s-anand.net/blog/assets/flickr-how-the-noerror-function-is-used_231297815_o-gif.webp&#34;&gt;&lt;img alt=&#34;How the NOERROR function is used&#34; loading=&#34;lazy&#34; src=&#34;https://www.s-anand.net/blog/assets/flickr-how-the-noerror-function-is-used_231297815_o-gif.webp&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Notice that cell E2 would&amp;rsquo;ve had a #N/A error if you&amp;rsquo;d just used the VLOOKUP. This function also filters out #REF, #DIV/0!, #NAME? and all other errors.&lt;/p&gt;
&lt;p&gt;BTW, you see column F displaying the formula in column E. I didn&amp;rsquo;t type it out. That&amp;rsquo;s another UDF.&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://www.s-anand.net/blog/assets/flickr-formulastring-function-returns-the-formula-of-a-cell_231297817_o-gif.webp&#34;&gt;&lt;img alt=&#34;FormulaString function returns the formula of a cell&#34; loading=&#34;lazy&#34; src=&#34;https://www.s-anand.net/blog/assets/flickr-formulastring-function-returns-the-formula-of-a-cell_231297817_o-gif.webp&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I will talk about the other two places where you use UDFs tomorrow.&lt;/p&gt;
&lt;hr&gt;
&lt;h2 id=&#34;comments&#34;&gt;Comments&lt;/h2&gt;
&lt;!-- wp-comments-start --&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Greg&lt;/strong&gt; &lt;em&gt;4 Apr 2007 3:15 pm&lt;/em&gt;:
This is very helpful! I am having a problem however; I defined the functions in personal.xls (loaded upon startup) and they always work there, but they aren&amp;rsquo;t available when working with a different file (I get the #NAME error). I also then created variants of them in the specific file, but although they worked, once I made some changes in the file (added a column), they no longer worked even though I re-did the reference properly. Any ideas?&lt;/li&gt;
&lt;/ul&gt;
&lt;!-- wp-comments-end --&gt;
</description>
    </item>
    <item>
      <title>Excel - Make your model visually obvious</title>
      <link>https://www.s-anand.net/blog/excel-make-your-model-visually-obvious/</link>
      <pubDate>Sat, 24 Dec 2005 12:00:00 +0000</pubDate>
      <guid>https://www.s-anand.net/blog/excel-make-your-model-visually-obvious/</guid>
      <description>&lt;p&gt;Rule #4: Make your model &lt;strong&gt;visually obvious.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;After years of creating Excel models with lots of inputs and lots of outputs, I&amp;rsquo;ve learnt two things.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Usually, only ONE input parameter matters&lt;/strong&gt;. Think of this as being the constraint in the &lt;a href=&#34;http://en.wikipedia.org/wiki/Theory_of_constraints&#34;&gt;Theory of Constraints&lt;/a&gt;, or the principal component in &lt;a href=&#34;http://en.wikipedia.org/wiki/Factor_analysis&#34;&gt;factor analysis&lt;/a&gt;. You want your model to communicate the impact of the ONE parameter, and get a decision based on that. Keep the rest at their best default value.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Usually, only ONE output function matters&lt;/strong&gt;. This is either a single number, or at most, a visually obvious function.&lt;/p&gt;
&lt;p&gt;For example, I was working on creating an offshore test centre. The question was: what test activities should we outsource? I made a huge model evaluating 1,200 activities. A very elegant model. And totally incomprehensible. The issue really was simple. We could not recruit too fast. But at the same time, the more we offshore, the more the cost savings. So I built a summary sheet that showed the impact of one parameter (speed of ramp-up) on one function (offshore profile).&lt;/p&gt;
&lt;p&gt;&lt;a href=&#34;https://www.s-anand.net/blog/assets/flickr-offshore-ramp-up-profile_76842359_o-gif.webp&#34;&gt;&lt;img alt=&#34;Offshore ramp-up profile&#34; loading=&#34;lazy&#34; src=&#34;https://www.s-anand.net/blog/assets/flickr-offshore-ramp-up-profile_76842359_o-gif.webp&#34;&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;The fixed blue line shows the number of people required. The slider on the right ranges from &amp;ldquo;conservative ramp-up&amp;rdquo; to &amp;ldquo;aggressive ramp-up&amp;rdquo;. The green line shows how many resources will be offshore. In the conservative ramp-up, the recruitment rate is very manageable, but the saving is negligible, since hardly anyone is offshore. The aggressive ramp-up calls for an unmanageable ramp-up rate.&lt;/p&gt;
&lt;p&gt;We showed the management this tradeoff. They said, &amp;ldquo;We can recruit 30 people next year&amp;rdquo;. That implied the moderate ramp-up scenario, and a cost saving of 27%. Total time spent in making decision: 2 minutes.&lt;/p&gt;
&lt;p&gt;Creating a slider-based model is quite useful. You can download a &lt;a href=&#34;https://files.s-anand.net/blog/a/Animation.xls&#34;&gt;US Treasury yields&lt;/a&gt; example to see how this is done. As you move the slider, the yield curve moves over time, showing how it has fluctuated. The trick is to:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;build the entire model based on a single cell&lt;/strong&gt;. Cell H1 in this example acts as the index to the dates.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;create a slider&lt;/strong&gt;. Go to View - Toolbars - Control Toolbox and add a slider.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;and link the slider to the cell&lt;/strong&gt;. Right-click on the cell in design mode, select View Code, and type Range(&amp;ldquo;H1&amp;rdquo;).Value = ScrollBar1.Value in the Scrollbar change event.&lt;/li&gt;
&lt;/ol&gt;
&lt;hr&gt;
&lt;h2 id=&#34;comments&#34;&gt;Comments&lt;/h2&gt;
&lt;!-- wp-comments-start --&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Vasant&lt;/strong&gt; &lt;em&gt;5 Jan 2006 10:35 am&lt;/em&gt;:
A very wise observation - that only one parameter and function finally matters in a complex model. Thanks&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Joe G.&lt;/strong&gt; &lt;em&gt;21 Jan 2009 5:05 pm&lt;/em&gt;:
Hi, I&amp;rsquo;m trying to modify the value in cell H1 to reflect new data that I have added to the table. The chart works at first, but as soon as I scroll away from the new dates that I added, they disappear and default back to the 229 that was originally in the cell.&lt;br&gt;
&lt;br&gt;
How do I change the value and keep it changed?&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;S Anand&lt;/strong&gt; &lt;em&gt;29 Jan 2009 9:45 am&lt;/em&gt;:
Go to design mode first. (On Office 2007, that&amp;rsquo;s under Developer -&lt;br&gt;
Design mode. On Office 2003, View - Toolbars - Control Toolbox the&lt;br&gt;
design mode icon.)&lt;br&gt;
&lt;br&gt;
Right-click the slider, select properties, and change the &amp;ldquo;Max&amp;rdquo; field&lt;br&gt;
from 229 to your desired value.&lt;/li&gt;
&lt;/ul&gt;
&lt;!-- wp-comments-end --&gt;
</description>
    </item>
  </channel>
</rss>
