Everything about PowerPoint programming including VBA, VSTO, and more.
See Also:
PowerPoint and Presenting Notes
PowerPoint and Presenting Glossary
Ever tried copying an object in PowerPoint and found it refuses to sit still when pasted? Instead of landing neatly atop the original—like a twin returning to its bunk bed—it drifts off like a rebellious balloon, as shown in Figure 1, below. This default offset paste behavior can be especially annoying when working with precise layouts, animations, or rotational effects that demand pixel-perfect placement. That’s where VBA steps in like a backstage ninja, letting you paste objects exactly where you want—no nudging required.

Figure 1: Pasted object is offset from the original
Before you unleash your PowerPoint-fueled sorcery, here’s the first step: you need to know how to run VBA scripts in PowerPoint. Think of it like discovering a hidden trapdoor backstage — once you find it, you can rig all kinds of magical effects.
It’s not complicated, but it’s a bit like finding the remote that controls the presentation behind the curtain. Once you’re in, you’ll meet VBA — Visual Basic for Applications — a kind of techy whisperer that tells PowerPoint to behave exactly the way you want. Like pasting objects exactly in place instead of letting them wander like lost ducks.
Then, you will use this code. Explore the code a bit though.
Option Explicit Sub PasteInPlace() Dim sld As Slide Dim shp As Shape Set sld = Application.ActiveWindow.View.Slide Dim y As Single Dim x As Single y = ActiveWindow.Selection.ShapeRange.Top x = ActiveWindow.Selection.ShapeRange.Left Windows(1).Selection.Copy ActivePresentation.Slides(sld.SlideIndex).Shapes.Paste ActivePresentation.Slides(sld.SlideIndex).Shapes(ActivePresentation.Slides(sld.SlideIndex).Shapes.Count).Top = y ActivePresentation.Slides(sld.SlideIndex).Shapes(ActivePresentation.Slides(sld.SlideIndex).Shapes.Count).Left = x End Sub
Alright, you’ve just dropped that magical VBA code into PowerPoint’s secret command center — the VBA Editor. Now, close that window and return to your slide deck like a superhero stepping back from their gadget lab.
But hold up! Before you start testing your macro-powered wizardry, save your file — and not just any old way. You need to use the PowerPoint Macro-Enabled Presentation format — the one with the .PPTM extension. If you save as any of the other file formats, PowerPoint will offer to remove the macros, and then, of course, the code to paste in place will not work! See our PowerPoint File Formats page to learn about these file formats.
Now that your macro is ready for action, it’s time to flip the switch — like starting the popcorn machine before movie night.

We ran this code using PowerPoint 365 for Windows, and it behaved like a well-trained puppy — responsive, obedient, and surprisingly agile. Now here’s the twist: we haven’t tried it on PowerPoint 365 for Mac yet. It might work like a charm… or throw a tantrum like a vending machine that eats your coins. Only a brave Mac user can tell us! So, if you give this VBA code a spin on your Mac — and it does work (or even if it flat-out rebels) — we’d love to hear about it. Drop us a comment below like you’re giving Yelp feedback for a secret recipe.
Windows users, you’re not off the hook either! If you spot quirks, bonus tricks, or even just want to say “Yep, this worked!” — share your thoughts too. Community wisdom beats lone-wolf coding any day!
Many thanks to Marcin Mikuszewski who suggested some changes to the code. Thanks for helping this community, Marcin.
You May Also Like: Use VBA in PowerPoint, Even if You Can’t Program for Nuts | Resources on PowerPoint Programming and VBA
Filed Under:
Programming
Tagged as: PowerPoint, Programming, Snippets, VBA
Comments Off on VBA Code: Paste in Place

John Korchok has been creating reliable branded Office templates and web sites for more than 20 years. He is certified as a Microsoft Office Specialist Master, is an award-winning technical writer and is skilled in programming VBA, JavaScript for PDF and web, HTML, CSS, and PHP. John is a moderator for Microsoft Answers and a volunteer at Stack Overflow, providing answers for Word and PowerPoint for Windows and macOS. He currently works for Brandwares in metropolitan New York.
In this conversation, John talks about his new Icon Gallery add-in for PowerPoint.
Filed Under:
Interviews
Tagged as: Add-in, Interviews, John Korchok, Programming
Comments Off on Icon Gallery Add-in for PowerPoint: Conversation with John Korchok
Have you created or inherited a PowerPoint file that contains a linked video file that you want to share with others? Wouldn’t it be easier if you could send your recipients a PowerPoint file that contained all the videos as part of the file, rather than send them the linked videos separately?

Filed Under:
Programming
Tagged as: PowerPoint, Programming, Snippets, Steve Rindsberg, VBA
Comments Off on VBA Code: Change Linked Videos to Embedded?
By John Korchok
We looked at the basics of XML programming in our Introducing XML Hacking in Microsoft Office post. Now, let us take this concept further. Let’s start hacking some XML with a simple project: setting the default table text size.
This article assumes you have a suitable text editor installed. Mac users should also read the XML Hacking: Editing in OS X post.
When you insert a new table in PowerPoint, the default table text size is 18 points. Using XML hacking, we can set this to whatever point size the designer prefers. You can also set the text to appear in all caps. Following the previous post’s instructions, add .ZIP to the file ending and unzip the file. Look for the ppt folder and open it:
Filed Under:
XML
Tagged as: John Korchok, XML
By John Korchok
With the introduction of Office 2007, Microsoft changed the basic file format that underlies Word, PowerPoint, and Excel. Instead of the proprietary and mostly undocumented format that ruled from Office 97 to Office 2003, Microsoft made a smart decision and switched to XML. This is tagged text, similar in structure and concept to HTML code with which you may already be familiar.
XML opens up a world of possibilities for automated document construction, but that’s a topic for another day. The everyday relevance is that if a Word or PowerPoint file isn’t doing what you need it to do and there are no tools in the program for the job, we can now dive in and edit the file ourselves. If you’re a point-and-click user, this is probably not thrilling. But if you’re a hacker at heart, a midnight coder, or just a curious tinkerer, you can do some cool stuff.
Filed Under:
XML
Tagged as: John Korchok, XML
Comments Off on Introducing XML Hacking in Microsoft Office
Microsoft and the Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries.