title: Python: Activate last slide in active PowerPoint presentation
body: <p>I'd like to add a slide to an active PowerPoint presentation, and activate it (make it visible) at the same time.</p>
  
  <p>Using Python, the snippet below will add a slide to an active PowerPoint presentation. I'm using that together with functions like <code>Base.Shapes.AddPicture</code> to add pictures that I've produced with matplotlib, but I'm leaving that part out here.</p>
  
  <p><strong>Run this once:</strong></p>
  
  <pre><code>import win32com.client
  Application = win32com.client.Dispatch("PowerPoint.Application")
  Presentation = Application.Activepresentation
  slidenr = Presentation.Slides.Count + 1
  Base = Presentation.Slides.Add(slidenr, 12)
  </code></pre>
  
  <p><strong>And you'll get this:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/D8Tbj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/D8Tbj.png" alt="enter image description here"></a></p>
  
  <p>So far so good. But run it a bunch of times, and you'll end up with the situation described in the picture below. Notice that you'll have to use the scrollbar to see the last produced slide.</p>
  
  <p><a href="https://i.stack.imgur.com/BPIH9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BPIH9.png" alt="enter image description here"></a></p>
  
  <p>This messes with my work-flow, since I'd like to produce a chart, send it to PowerPoint, make a few adjusments, send a new version to PowerPoint and inspect it without having to switch from my python IDE to PowerPoint.</p>
  
  <p>I thought this would be the easiest thing in the world to accomplish, but I've found nothing on SO, in the <a href="https://python-pptx.readthedocs.io/en/latest/" rel="nofollow noreferrer">docs</a> or elsewhere. Maybe my googling abilities are just horrible...</p>
  
  <p>Anyway, thank you for any suggestions!</p>