VEGA SLIDE

How to Open and Use VBA Macro Editor in PowerPoint

powerpoint presentation vba code

Are you tired of manually performing repetitive tasks in PowerPoint? Look no further than the open VBA Macro editor in PowerPoint 2021. Whether you’re a seasoned PowerPoint user or just getting started, understanding how to use the VBA Macro editor can drastically improve your workflow.

Table of Contents

What is vba.

VBA stands for Visual Basic for Applications. It is a programming language that is used to extend the functionality of Microsoft Office applications like Excel, Word, and PowerPoint.

A VBA macro is a piece of code written in VBA that performs a series of tasks or commands in a Microsoft application. They can automate repetitive and complex tasks to save time and manual work. So, VBA is the language used to write macros, while macros are the code that is written using VBA.

Steps to open the VBA macro editor

1. Create a new presentation or open an existing one. Then go to the File tab and click on Options .

powerpoint presentation vba code

2. Click on Customize Ribbon , and check the box next to Developer and click OK .

powerpoint presentation vba code

3. Go to the Developer tab and click on Visual Basic . Another way is to press Alt + F11 on your keyboard. This will open the VBA Macro editor in a separate window.

powerpoint presentation vba code

4. In the VBA Macro editor, you can see the Project Explorer pane on the left, which shows all the modules and objects in your presentation. You can also see the Code window on the right, where you can write and edit your VBA code.

powerpoint presentation vba code

5. To create a new module, go to the Insert menu and click on Module .

powerpoint presentation vba code

6. A new module will appear in the Project Explorer pane with a default name like Module1 .

powerpoint presentation vba code

7. To create a new macro, type Sub followed by a name for your macro in the Code window. For example, Sub HelloWorld() . Then press Enter and type End Sub on a new line. This will create a basic macro structure with a name and an empty body.

powerpoint presentation vba code

8. To write your VBA code, type it between Sub and End Sub lines. For example, to make a message box pop up with the text “Hello World”, type MsgBox “Hello World” on a new line.

powerpoint presentation vba code

9. To run your macro, go to the Run menu and click on Run Sub/UserForm or press F5 .  

powerpoint presentation vba code

10. You should see a message box with the text “Hello World” appear on your screen.

powerpoint presentation vba code

You have successfully opened the VBA Macro editor in PowerPoint 2021 and created your first macro. You can now explore more VBA features and functions and create more complex and powerful macros for your presentations.

How do I open the VBA editor in PowerPoint?

The quickest way to open the VBA editor in PowerPoint is by pressing Alt+F11 . Laptop users may need to combine it with Fn .

You may also enable the Developer tab. Go to Developer > Macros . Select the macro and click Run .

How do I edit VBA code in PowerPoint?

Open the VBA editor by pressing Alt+F11 . Select the macro in the Macros dialog box and click Edit . This opens the code for editing.

How do I create a new VBA module in PowerPoint?

powerpoint presentation vba code

To create a new VBA module in PowerPoint, first open the VBA editor by pressing ALT+F11 . Once the VBA editor is open, insert a new module by going to Insert > Module . This will insert a blank code module. This allows you to automate tasks and add functionality in PowerPoint using VBA programming.

How can I assign a keyboard shortcut to run a macro in PowerPoint?

To assign a keyboard shortcut to a macro in PowerPoint, first create the macro and write the VBA code. Then go to the File > Options > Customize Ribbon . In the box on the left, select Macros . Then select the macro you want to assign a shortcut to from the list on the right.

Click the Add button to add it to the customizable shortcuts. Click the Modify button. In the Modify Button dialog box, enter the keyboard shortcut you want to assign in the Press new shortcut key box (e.g. “^+G” for Ctrl+Shift+G). Click Assign , then OK . Now you can quickly execute the macro by pressing the keyboard shortcut instead of going through the ribbons.

How can I debug VBA code in the PowerPoint editor?

I find the easiest way to debug VBA code in PowerPoint is to use the built-in debugging tools.

First, I open the Visual Basic editor by pressing Alt+F11 . Then I set breakpoints in my code by clicking in the left margin of the line numbers. When I run the code with F5 , it will pause execution at any breakpoint I set so I can step through my code line-by-line with F8 and inspect variables.

I also use the Immediate window (Ctrl+G) and Debug.Print statements to output variable values. With these tools, I can methodically walk through my code to identify and fix any issues.

About The Author

Rully novrianto, related posts.

powerpoint presentation vba code

How to Stop Compressing Images in PowerPoint 2013

powerpoint presentation vba code

PowerPoint vs. Keynote vs. Google Slides: Which One to Choose

powerpoint presentation vba code

How to Convert Google Slides to PowerPoint and Vice-Versa

powerpoint presentation vba code

How to Create a Slide Master in Microsoft PowerPoint

powerpoint presentation vba code

Run a macro in PowerPoint

To run a macro in PowerPoint, the Developer tab must be visible on the ribbon. See Show the Developer tab .

With the Developer tab visible:

On the Developer tab, in the Code group, click Macros .

In the Macro dialog box, under Macro name , select the macro that you want, and then click Run .

For information about the security risks of macros and enabling or disabling macros in presentations in the Trust Center , see Enable or disable macros in Office documents .

If you want to create or edit a macro, you must use Visual Basic for Applications (VBA).

Facebook

Need more help?

Want more options.

Explore subscription benefits, browse training courses, learn how to secure your device, and more.

powerpoint presentation vba code

Microsoft 365 subscription benefits

powerpoint presentation vba code

Microsoft 365 training

powerpoint presentation vba code

Microsoft security

powerpoint presentation vba code

Accessibility center

Communities help you ask and answer questions, give feedback, and hear from experts with rich knowledge.

powerpoint presentation vba code

Ask the Microsoft Community

powerpoint presentation vba code

Microsoft Tech Community

powerpoint presentation vba code

Windows Insiders

Microsoft 365 Insiders

Was this information helpful?

Thank you for your feedback.

powerpoint presentation vba code

  • Charts and Graphs , Excel Howtos , VBA Macros

Create PowerPoint Presentations Automatically using VBA

  • Last updated on May 20, 2020

Chandoo

This is a guest post by Drew Kesler. 

You’ve been there before. It’s almost 5:00, and you are going crazy trying to finish the presentation due for a monthly performance meeting the next morning. The model is refreshed, and now it just takes a LOT of copying, pasting, and positioning to get the PowerPoint ready. Finally, the slides are finished…, until you read a new message from your boss requesting a minor change. But of course her change means you have to start all over with the copy and pastes…

There is always a better way! In the Oil and Gas industry, I constantly have monthly reports to assess the performance of our operating assets. Excel VBA makes it a cinch to automate the entire process. So when a simple change is requested, the presentation is automatically generated with the click of a button. No more wasting time!

So, here it is – How to Save TONS of Time by Using an Excel VBA Macro to Build Your Presentation:

1. Build your charts in Excel

Excel to PowerPoint using VBA - Step 2

3. Open VBA. To do this, you can either press ALT + F11, or you can take the following steps:

Excel to PowerPoint using VBA - Step 3a

7. Now all you need to do is go to Excel and run the CreatePowerPoint macro! To make this easy, draw a rectangle shape in your Excel worksheet which contains all the charts you want to export to PowerPoint.

Excel to PowerPoint using VBA - Step 7

Download the Example Workbook & Play with this Macro

Click here to download the example workbook and play with the macro .

Note: If you have an error with Power Point application activation, use this code instead.

Thanks Drew

Thank you so much Drew for writing this insightful article and showing us how to automate PPT Creation thru Excel VBA. I have really enjoyed playing this idea. And I am sure our readers will also like it.

If you like this technique, say thanks to Drew.

How do you Automate PPT Creation?

During my day job, I used to make a lot of presentations. But each one was different. So I used to spend hours crafting them.

And nowadays, I hardly make a presentation. But I know many of you make PPTs day in day out. And this technique presented by Drew is a very powerful way to save time.

Do you use macros to automate creation of presentations? What are your favorite tricks & ideas? Please share using comments.

Learn More VBA – Sign-up for our VBA Class Waiting List

Chandoo.org runs a VBA Class that teaches you from scratch, how to build macros to save time & automate your work. We opened our first batch in May this year and had an excellent response. More than 650 students signed up and are now learning VBA each day.

If you want to learn VBA & advanced Excel, this is a very good class to join.

Click here for full information on VBA classes .

About the Author:

Drew Kesler specializes in process automation and data visualization. He currently performs analytics and modeling for the Oil and Gas industry. His most recent projects include using GIS mapping technology to visualize data and enhance interaction across organizations.

Share this tip with your colleagues

Excel and Power BI tips - Chandoo.org Newsletter

Get FREE Excel + Power BI Tips

Simple, fun and useful emails, once per week. Learn & be awesome.

  • 212 Comments
  • Ask a question or say something...
  • Tagged under advanced excel , Automation , charting , downloads , guest posts , Learn Excel , macros , powerpoint
  • Category: Charts and Graphs , Excel Howtos , VBA Macros

powerpoint presentation vba code

Welcome to Chandoo.org

Thank you so much for visiting. My aim is to make you awesome in Excel & Power BI. I do this by sharing videos, tips, examples and downloads on this website. There are more than 1,000 pages with all things Excel, Power BI, Dashboards & VBA here. Go ahead and spend few minutes to be AWESOME. Read my story • FREE Excel tips book

powerpoint presentation vba code

Want an AWESOME Excel Class?

Advanced Excel & Dashboards training - Excel School is here

– Brenda

FREE Goodies for you...

Excel formula list - 100+ examples and howto guide for you

From simple to complex, there is a formula for every occasion. Check out the list now.

powerpoint presentation vba code

Calendars, invoices, trackers and much more. All free, fun and fantastic.

Advanced Pivot Table tricks

Power Query, Data model, DAX, Filters, Slicers, Conditional formats and beautiful charts. It's all here.

powerpoint presentation vba code

Still on fence about Power BI? In this getting started guide, learn what is Power BI, how to get it and how to create your first report from scratch.

Downloadable Excel Gender Pay Gap calculator template.

How to calculate the Gender Pay Gap using Excel Formulas? (Free Calculator Template)

Gender Pay Gap is the difference in pay for groups of men & women and usually based on the average or median salaries. We can use Microsoft Excel to quickly calculate the GPG (Gender Pay Gap) from your data. In this article, let me explain the process, Excel formulas and offer you a ready to use GPG calculator.

Weighted Average in Excel with Percentage Weights

Weighted Average in Excel [Formulas]

powerpoint presentation vba code

How to get non-adjacent columns with FILTER function in Excel

xlookup function in Excel - how to use it?

What is XLOOKUP and how to use it in Excel?

Get bolded portions of a column using getBoldText function

Extract BOLD portion of a cell in Excel using getBoldText() function

  • Excel for beginners
  • Advanced Excel Skills
  • Excel Dashboards
  • Complete guide to Pivot Tables
  • Top 10 Excel Formulas
  • Excel Shortcuts
  • #Awesome Budget vs. Actual Chart
  • 40+ VBA Examples

Related Tips

powerpoint presentation vba code

How to fix SPILL Error in Excel Tables (3 easy solutions)

How-to create dependent drop downs in excel [dynamic & multiple].

time between two dates excel formula

How to calculate time between two dates in Years, Months & Days [Excel Formula]

212 responses to “create powerpoint presentations automatically using vba”.

' src=

Hmmm...whilst that'd be very handy sometimes, I've often found it's quicker and easier to simply link the charts to a PowerPoint, meaning that any time you update the chart, you update the PPT too.

' src=

Wondering if there is a way to actually use excel slicers while in PowerPoint Presentation mode. I figured out how to incorporate the slicers into the PPT but when you switch to presentation mode, you can't click on an fields to change the details. Anyone know if this can be done?

' src=

we have prepared a simple and useful solution for that issue. Check the following video, where its presented: http://www.youtube.com/watch?v=inBBlpd9qQ4

You will find the contact information and we will provide you that Add-in.

Than really saves you a lot of time!!

' src=

I want to create a ppt but to take each chart and table from every sheet. how can I do it?

question 2: If my ppt already exists and there has been a change in the data, I need the charts and tables to only update in my ppt. how do you suggest I solve it?

' src=

Hey here is a "cool" VBA-Code to create on the first slide thumbnails of all slides ! Regards Stef@n

Sub thumbnails() Dim strPath As String Dim i As Integer Dim n As Integer Dim sld As Slide

strPath = ActivePresentation.Path n = ActivePresentation.Slides.Count

ActivePresentation.SaveAs FileName:=strPath & "\Test.png", _ FileFormat:=ppSaveAsPNG, EmbedTrueTypeFonts:=msoFalse Set sld = ActivePresentation.Slides.Add(1, ppLayoutBlank) For i = 1 To n sld.Shapes.AddPicture FileName:=strPath & "\Test\slide" & i & _ ".PNG", LinkToFile:=msoFalse, SaveWithDocument:=msoTrue, Left:=i * 30, _ Top:=i * 30, Width:=144, Height:=108 Next i End Sub

' src=

Hi, I can't make it work. 🙁 I get the error 424: Object required. I suppose this is because of an object library is not properly referenced, but which?   Thanks!

' src=

I too am getting this error and can get the sample file to work. This would be great for a project I am currently working on.

' src=

It is not clear to me from the trailing posts if the problem with the above not working has been fixed. However, the slightly modified code below works with Office 2010 (Powerpoint), and produces a slide with thumbnails (iMaxSlidesHorizontal (8) to a row).

Sub thumbnails()

Dim iFullHeight As Integer iFullHeight = 0 Dim iFullWidth As Integer iFullWidth = 0

Dim iHeight As Integer iHeight = 108 Dim iHSpacing As Integer iHSpacing = 10

Dim iMaxSlidesHorizontal As Integer iMaxSlidesHorizontal = 8 Dim iVSpacing As Integer iVSpacing = 10 Dim iWidth As Integer iWidth = 144 Dim n As Integer n = ActivePresentation.Slides.Count Dim strPath As String strPath = ActivePresentation.Path

Dim sld As Slide Dim i As Integer

Dim iSlidesHorizontal As Integer iSlidesHorizontal = 0 Dim iSlidesVertical As Integer iSlidesVertical = 0

ActivePresentation.SaveAs FileName:=strPath & "\Test.PNG", FileFormat:=ppSaveAsPNG, EmbedTrueTypeFonts:=msoFalse Set sld = ActivePresentation.Slides.Add(1, ppLayoutBlank)

For i = 1 To n

sld.Shapes.AddPicture FileName:=strPath & "\Test\slide" _ & i _ & ".PNG", _ LinkToFile:=msoFalse, _ SaveWithDocument:=msoTrue, _ Left:=iSlidesHorizontal * (iWidth + iHSpacing), Top:=iSlidesVertical * (iHeight + iVSpacing), _ Width:=iWidth, _ Height:=iHeight

iSlidesHorizontal = iSlidesHorizontal + 1

If iSlidesHorizontal >= iMaxSlideHorizontal Then

iSlidesHorizontal = 0 iSlidesVertical = iSlidesVertical + 1

' src=

this code says runtime error 429 ActiveX component cant create object. can you please help

@ steve i agree ! regards Stef@n

' src=

On occasions I have to create a large number of photo sheets for inclusion in a report. That is, a page with one or two photos and a description. Using a list in an excel spreadsheet that gives the file name for the photo and a description I written a macro to generate a powerpoint presentation that can be saved as a pdf or printed out. Any changes to photo or description are simple to do in the list.

' src=

Datapig had a similar method.

http://datapigtechnologies.com/blog/index.php/creating-a-powepoint-deck-in-excel/

This works in 2003

' src=

I downloaded the example spreadsheet in Create PowerPoint Presentations Automatically using VBA. Excel says this file is not in Excel format even though it has an .xls extension. I am using Excel2003. Any ideas?

' src=

How do you copy charts from excel into PowerPoint as ChartObjects (not metafile or linked image)? In excel 2003 we had the graph engine which enabled us to paste the chart data into Graph.DataSheet. Whats the equivalent in Office 2010??

' src=

I have a few large presentations (~300 slides). My approach was to make a chart for every possible permutation, then link them all into PowerPoint. The powerPoint works like a website, so the user can click around to get to the chart they are interested in within 1-2 clicks.

Unfortunately, this approach doesn't seem to work in Office 2007. First, it takes forever to update the links, if it does it at all. Second, once they are updated, when you go into slide show view in PowerPoint the fonts are all fuzzy (I've looked into this and it has something to do with the way PP07 scales the slides). There appears to be no solution to this so now I need a new approach...

I've tested the following approach a little and it seems to work. I have a sub that exports all the charts out as images:

Sub Export2Image() Dim oCht As ChartObject Dim flPath As String, fName As String Dim ws As Worksheet Dim cs As Chart Dim i As Long flPath = "C:\Excel\Exports" 'Put files in this folder ChDir flPath For Each cs In ActiveWorkbook.Charts i = i + 1 fName = cs.Name & i & ".jpg" cs.Export Filename:=fName, FilterName:="jpg" Next For Each ws In ActiveWorkbook.Worksheets For Each oCht In ws.ChartObjects i = i + 1 fName = ws.Name & i & ".jpg" oCht.Chart.Export Filename:=fName, FilterName:="jpg" Next Next

'MsgBox ("All workbook charts have been exported as images to ") & flPath & ".", vbOKOnly

Then in PowerPoint I link to the image on the file server. The only problem I've noticed is some of the charts have the little red "X" in the corner, but it goes away after a second or two. Though this approach seems to be viable, I am open to other suggestions. I tried the code above, but it doesn't really work for me because I have set slides with set text, I only need to update the chart.

' src=

@GrahamG : Can you share a file and procedure as you mentioned on your comment?

@Drew: Wow thanks for sharing the info...you're a life saver.

Can someone post on how to modify the VB script for the case below:

If you have a mixture of Chart and Picture in your workbook or if you have pictures only.

Meaning the presentation should be created using the pictures from excel the excel workbook, with comments as on the example sheet ofcourse.

Please help!!!

' src=

Thanks Drew, Its really useful code to work on powerpoint. If we can export it to excel again it may be awesome.

' src=

My choice is steve's because most ofthen than not you have made other customization on the powerpoint slide/chart.

But it is great to know new technique.

' src=

@Donald: Use the CopyPicture method. For example, if you go into drew's code, you will see the line: ActiveChart.ChartArea.Copy Change that to the following line: Sheet1.Range("A1:I19").CopyPicture xlScreen, xlPicture ------------------------------------------------------------------------------ Note that when you run the program it copies the contents of A1:I19 onto your presentation from Sheet1. Hope that helps!

Here's a link to the CopyPicture method: http://msdn.microsoft.com/en-us/library/bb148266.aspx .

Also, I've used and much prefer Drew's method overall. If your PowerPoint presentation is a report, then linking to the data source isn't always best when you need to send the presentation to your client or to another office branch, both of which might be outside of your network. Furthermore, generating a new presentation upon changes effectively creates an historical record. And finally, creating a presentation that isn't linked to the data source "walls off" your actual data such that nefarious and reckless can't harm it!

' src=

nice post. I have done something similar on my blog:

http://www.clearlyandsimply.com/clearly_and_simply/2010/03/export-microsoft-excel-dashboards-to-powerpoint.html

I thought you might be interested.

Along the same lines: I also had an article describing how to export a Microsoft Project Gantt chartto PowerPoint.

The interesting part of the Project VBA export procedure is the fact that it does not export the Gantt as a picture. It rather creates a project plan in PowerPoint consisting of PPT objects like textboxes, rectangles, triangles and diamonds. You can format, align, rearrange, group and resize them, add annotations, delete single items, etc. in PowerPoint.

This may be a bit off topic, because Chandoo.org is a Microsoft Excel blog, but if you are using Microsoft Project, too, you may want to have a look:

http://www.clearlyandsimply.com/clearly_and_simply/2009/03/gantt-charts-are-learning-to-fly.html

' src=

thanks for sharing the trick. However, is it possible to export in a chart format instead of picture format?

' src=

@ drew, THANK YOU for sharing, and starting this thread. @ everyone else, yes there are different ways of doing things. Sometimes your solutions would be better than drew's and sometimes drew's will be a better method. thanks for sharing your solutions @chandoo/hui can you make it easy to understand each option by expanding on this thread?

' src=

Select your chart in Excel, Go to PowerPoint and do Paste Special> Choose PasteLink> Choose Microsoft Excel Chart Object. You are done.

Now whenever you change your excel, just update link of Powerpoint. Your Chart will instantly updated.

' src=

hay its cool but it uses blank PPT tamplate what about using Companys own PPt Tamplet

[...] link [...]

@FINCRIBE create and save the PPT-Template as a POT-file Regards Stef@n

' src=

is it possible to modify the VBA to copy all charts from all worksheets into 1 single powerpoint file?

reason is that multiple charts are scattered across few worksheets and it'd be easier (or lazier) to copy ALL charts 😛

btw, any chance to perform similar copy-n-paste to Outlook Email (HTML)?

as u know, bosses hate to open attachments and would rather browse the charts via Blackberry!!

' src=

I've used this post to great effect already - many thanks for sharing!

I was wondering if the code could be modified so that rather than exporting charts to powerpoint, you could export a table?

noticed there is a bug/limitation.

if a chart is smaller than a powerpoint slide size, it works.

however, if a chart (or combo grouped-charts) is large, the VBA will not run.

error box: "Run-time error -2147418113 (8000ffff)': Method 'Copy' of object 'ChartArea' failed"

if i Debug, it will point to "ActiveChart.ChartArea.Copy"

' src=

@Davidlim: If you look on the earlier comments, robert posted a similar tehnique and on his example he has the chart/pic on different worksheets. When you execure the VB script it gives you option to open your existing template/file where the slide will be added last, meaning your presetation backround remains. or if you click cancel it creates a completely new presentation. on his Excel file he uses the names. Go to this link for more info and for the file download.

It's very interesting.

Thanks to all that contribute to these comments and I'm glad that through chandoo we get help. http://www.clearlyandsimply.com/clearly_and_simply/2010/03/export-microsoft-excel-dashboards-to-powerpoint.html

' src=

Hi Chandoo,

It works perfectly. Is there a way out to export tables from excel 2007 to PPT using Macros & the exported tables shld be in editable form in PPT.

' src=

Does anyone know how you would adjust the code for this to pick up a camera tool snapshot instead?

' src=

How doe we chnage the data dynamically in the PPT iteslef so that the graphs get modifed .Becuase currently it gor imported as an image .To chnage i have to go back to excel chnage teh data and again export .

Are there any way to chnage the values in the PPT and create the graph then and there in the PPT itself

' src=

Hi Pankaj, I might be too late to respond ... By now you might have got your answer as well. Modify the below: activeSlide.Shapes.PasteSpecial(DataType:=ppPasteMetafilePicture).Select to: activeSlide.Shapes.PasteSpecial(DataType:=ppPasteMetafilePicture, Link:=msoTrue).Select -DG.

' src=

Love it - thanks for the tip - owe you a beer 😉

' src=

How can we do it for pictures (map objects)? Anone can help thanks in advance

' src=

Great tip and is very helpful - I have a standard company template and would like to automatically place the graphs and text into this could any one please advise how this can be done with adding to the VBA code supplied.

Many Thanks

If any body can demonstrate as I have not got my answer i.e. how to automatically place the picture (bitmap) and text associated with picture in ppt. Drew and Chandoo please help

' src=

How can use this same methond to copy range of cells?

' src=

***William - First, Use this function:

Function CopyPaste(slide, selection, aheight, awidth, atop, aleft) Set PPApp = GetObject(, "Powerpoint.Application") Set PPPres = PPApp.ActivePresentation PPApp.Activate Set PPSlide = PPPres.Slides(PPApp.ActiveWindow.selection.SlideRange.SlideIndex) PPApp.ActiveWindow.View.GotoSlide (PPPres.Slides.Count) PPApp.Activate PPApp.ActiveWindow.View.GotoSlide (slide) ' Reference LAST slide Set PPSlide = PPPres.Slides(PPApp.ActiveWindow.selection.SlideRange.SlideIndex) selection.CopyPicture Appearance:=xlScreen, _ Format:=xlBitmap PPSlide.Shapes.Paste.Select

Set sr = PPApp.ActiveWindow.selection.ShapeRange ' Resize: sr.Height = aheight sr.Width = awidth If sr.Width > 700 Then sr.Width = 700 End If If sr.Height > 420 Then sr.Height = 420 End If ' Realign: sr.Align msoAlignCenters, True 'sr.Align msoAlignMiddles, True sr.Top = atop ' If aleft 0 Then sr.Left = aleft '50 End If If Not IsMissing(drawBorder) Then

'Draw border for the shape range With sr.Line .Style = msoLineThinThin .Weight = 0.1 .DashStyle = msoLineSolid .ForeColor.RGB = RGB(0, 0, 0) End With End If ' Clean up Set PPSlide = Nothing Set PPPres = Nothing Set PPApp = Nothing End Function

THEN, this line in your code:

CopyPaste slide, selection, 200, 700, 82, 10 'this copies the Selected Range

*** IF you want a working file - please let me know if you want to know how to make this dynamic, please let me know so that I can email you the working file..

' src=

@Sai Swaroop Hey Sai, if you are still able I would really appreciate getting a working copy of that excel sheet. Thanks

' src=

Please e-mail me the working file.   [email protected]  

' src=

Please send me the working file... tq.. really need this....

' src=

I need to export a few hundred graphs from excel and put 5 to a page in powerpoint. The graphs need to be a specified size with a black border. Can anyone provide the visual basic code to accomplish this?

' src=

Hi. I am working with a project where we create several summary reports and graphs based on a set of Raw data. Up until recently we have been using a manual process to copy paste these in Powerpoint. Could someone tell me how to copy tables and graphs over several worksheets into one powerpoint presentation please? I have tried the Macro for charts and it works great but wondered if someone could show how to make it work for tables and other data on excel.

Is it also possible for the presentation to change dynamically as the raw data chagnes? Thanks, Swetha

' src=

I have the same issue as Pankaj - how can we update the code to paste it as a Chart object that can be edited in PowerPoint (linked or the Excel file or unlinked, doesn't matter). I tried replacing "ppPasteMetafilePicture" with "ppPasteOLEObject" but it's still pasting the charts as pictures. Thanks!

Hi sai swaroop i am interested in working file pls email at [email protected]

' src=

Hi Sai Swaroop,

Can you please email me the working file?

Thanks in advance. Much appreciated.

Regards, Chax. 

hey Chander,

Sent you the file.

' src=

Can you send me the working file thanks

' src=

Can you please send me the working file as I am bumping up with same errors.

Chandar &Sai,

Pls send the working file as I am bumping with invalid shapes error

[email protected]

Hi, I was able to paste the Excel chart into the PowerPoint as a chart object, but I'm having trouble editing it within the presentation. PowerPoint VBA does not seem to allow me to refer to the chart and edit the axis font, etc., but instead edits the axis font size, axis font color of the chart in Excel. I was wondering if anyone could help. This is what I have so far. Thank you!

cht.Select ActiveChart.ChartArea.Copy activeSlide.Shapes.PasteSpecial(DataType:=ppPasteChartObject).Select

'Adjust the positioning of the Chart on Powerpoint Slide newPowerPoint.ActiveWindow.Selection.ShapeRange.Width = 9 * 72 newPowerPoint.ActiveWindow.Selection.ShapeRange.Height = 5 * 72 newPowerPoint.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True newPowerPoint.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True

' src=

i have 5 graphs which should pasted on the PPT in single slide...can we do it automatically?

' src=

I dont know VB scripting or macros, but from what i understand its taking a chart as a object, but i have sheet with a lot of field names & respective numeric values from formuales.

But this code does not work on that, do we need to update this code ?

Or can you provide a new code ? [that would be of gr8 help] or if its there on your website wats the link coz i was unable to find it.

I am into software testing so we deal with a lot of data & numeric values & less of charts..........plz assist

And request you to post entries specific to the filed of software testing. We are always on the look out of process enhancements which helps improve efficiency specially if its saving time for the project.

' src=

Here is how to copy past the chart as an actual chart rather than the picture. The pasted chart will be linked to the excel sheet, so any change in the excel sheet will be reflected on the chart.

'Copy the chart and paste it into the PowerPoint as linked charts cht.Select ActiveChart.ChartArea.Copy

activeSlide.Shapes.Paste ' This new pasted chart is actually linked to the excel sheet With activeSlide.Shapes(activeSlide.Shapes.Count) 'The chart that was just pasted .Left = 15 .Top = 125 End With

' src=

really cool....this website has wonderful tips and tricks :). Thank you a ton!

' src=

Can I put several graphs on one slide

' src=

How can this be done using Excel 2003? I have tried but keep getting the error: Missing:Microsoft Powerpoint 12.0 Object Library. How can I fix this?

Hey Brian. You'll need to reference the correct Powerpoint library. Like in the example above, you'll first, go into the VBA editor. From there you'll select the Tools menu item and click "References...."

Now, you should see something like "MISSING: Missing:Microsoft Powerpoint 12.0 Object Library" in the list box. De-select it. Now scroll down and look for something like "Microsoft Powerpoint ## Object Library" (where the # is a number). Most likely, if you're using Excel 2003, it will be "Microsoft PowerPoint 9.0 Object Library."

' src=

@ graham I am interested to do the same. Can you share the file/code with me? Thanks!

' src=

Hi I need to loop through all the sheets in a work book and copy all the charts from one sheet to one Slide. Could u help??

see above Sub thumbnails() Dim strPath As String Dim i As Integer Dim n As Integer Dim sld As Slide

ActivePresentation.SaveAs FileName:=strPath & “\Test.png”, _ FileFormat:=ppSaveAsPNG, EmbedTrueTypeFonts:=msoFalse Set sld = ActivePresentation.Slides.Add(1, ppLayoutBlank) For i = 1 To n sld.Shapes.AddPicture FileName:=strPath & “\Test\slide” & i & _ “.PNG”, LinkToFile:=msoFalse, SaveWithDocument:=msoTrue, Left:=i * 30, _ Top:=i * 30, Width:=144, Height:=108 Next i End Sub

' src=

im using a excel for mac 2011, and I can't get it to work - i keep getting this error: compile method or data member not found

and it highlights the PasteSpecial in the code!

can someone please let me know how to fix this?

any help would be much appreciated

' src=

Hi, did you ever get to the bottom of this ? I've got the same problem.   thanks   Paul

' src=

did you manage to solve this by any chance?

' src=

i would like to add a code to use a particular template shown in the following:   PowerPoint.Application.ActivePresentation.ApplyTemplate "C:\Documents and Settings\myfile\Application Data\Microsoft\Templates\ShortTitle.pot"

But i'm getting a 429 error, claiming the ActiveX component cannot create the object.

What else can i do please?

' src=

Below is the code I use to open up a PP template. Also, Under Tools > References, you need to make sure the Microsoft PowerPoint 14.0 Object Library is checked. 

 Dim newPowerPoint As PowerPoint.Application         Dim pptPres As PowerPoint.Presentation         Dim activeSlide As PowerPoint.Slide         Dim cht As Excel.ChartObject         Dim file As String         file = "C:\Users\jbain\Documents\PowerPoint template_Span.pptx"         Dim pptcht As PowerPoint.Chart               'Look for existing instance         On Error Resume Next         Set newPowerPoint = GetObject(, "PowerPoint.Application")         On Error GoTo 0           'Let's create a new PowerPoint         If newPowerPoint Is Nothing Then             Set newPowerPoint = New PowerPoint.Application         End If     'Make a presentation in PowerPoint         If newPowerPoint.Presentations.Count = 0 Then         Set pptPres = newPowerPoint.Presentations.Open(file)         End If           'Show the PowerPoint         newPowerPoint.Visible = True 

hi Jenn, thank you for your reply. in the Tools > Reference, i only find Microsoft PowerPoint 12.0 Object Library. How do i get hold of Microsoft PowerPoint 14.0 Object Library please?

i'm using Office 2007.

Hi Aaron, I believe you are using Office 2007 and Jenn's using 2010. Hence the difference in Object Library version. You can try using Microsoft PowerPoint 12.0 Object Library and try. Please modify: PowerPoint.Application.ActivePresentation.ApplyTemplate “C:\Documents and Settings\myfile\Application Data\Microsoft\Templates\ShortTitle.pot” to: PowerPoint.ActivePresentation.ApplyTemplate “C:\Documents and Settings\myfile\Application Data\Microsoft\Templates\ShortTitle.pot” -DG.

thank you for your suggestion. i tried the modification, and now the error claims: '429' error. ActiveX component cannot create object.

highlighsts the code: PowerPoint.ActivePresentation.ApplyTemplate “C:\Documents and Settings\myfile\Application Data\Microsoft\Templates\ShortTitle.pot”

Any other suggestions i can try please?

' src=

Sub PushChartsToPPT() 'Set reference to 'Microsoft PowerPoint 12.0 Object Library' 'in the VBE via Tools > References... ' Dim ppt As PowerPoint.Application Dim pptPres As PowerPoint.Presentation Dim pptSld As PowerPoint.Slide Dim pptCL As PowerPoint.CustomLayout Dim pptShp As PowerPoint.Shape

Dim cht As Chart Dim ws As Worksheet Dim i As Long

Dim strPptTemplatePath As String

strPptTemplatePath = "E:\DC++ Downloads\Intern\Ormax\Macro\demo template.pptx"

'Get the PowerPoint Application object: Set ppt = CreateObject("PowerPoint.Application") ppt.Visible = msoTrue Set pptPres = ppt.Presentations.Open(strPptTemplatePath, untitled:=msoTrue)

'Get a Custom Layout: For Each pptCL In pptPres.SlideMaster.CustomLayouts If pptCL.Name = "Title and Content" Then Exit For Next pptCL

'Copy ALL charts in Chart Sheets: For Each cht In ActiveWorkbook.Charts Set pptSld = pptPres.Slides.AddSlide(pptPres.Slides.Count + 1, pptCL) pptSld.Select

For Each pptShp In pptSld.Shapes.Placeholders If pptShp.PlaceholderFormat.Type = ppPlaceholderObject Then Exit For Next pptShp If pptShp Is Nothing Then Stop

cht.ChartArea.Copy ppt.Activate pptShp.Select ppt.Windows(1).View.Paste Next cht

'Copy ALL charts embedded in EACH WorkSheet: For Each ws In ActiveWorkbook.Worksheets For i = 1 To ws.ChartObjects.Count Set pptSld = pptPres.Slides.AddSlide(pptPres.Slides.Count + 1, pptCL) pptSld.Select

For Each pptShp In pptSld.Shapes.Placeholders If pptShp.PlaceholderFormat.Type = ppPlaceholderObject Then Exit For Next pptShp

Set cht = ws.ChartObjects(i).Chart cht.ChartArea.Copy ppt.Activate pptShp.Select ppt.Windows(1).View.Paste Next i Next ws End Sub

I am using this code to link charts from excel to powerpoint. But this is inserting charts to last slide. Can anyone suggest me the changes so that i get charts to link with ppt to custom slide number and in mid of some saved template. Thanks in advance.

I have Microsoft 2010, which may be why mine is 14.0. Your version should work as well. The main thing is that the PowerPoint object library is references because the VBA code includes references to PowerPoint objects. 

Hi Aaron,   Apologies for the delay in response. Please try: newPowerPoint.ActivePresentation.ApplyTemplate "C:\Documents and Settings\myfile\Application Data\Microsoft\Templates\ShortTitle.pot"

thanks for your reply. i've tried it with the suggestion, but this time, error msg is: Operating error: -2147188160 (80048240)': Presentation (unknown member): Invalid request. PowerPoint could not open the file.

highlights the code: newPowerPoint.ActivePresentation.ApplyTemplate “C:\Documents and Settings\myfile\Application Data\Microsoft\Templates\ShortTitle.pot”

My codes as below. Is it possible you can find some error in the coding please?: 'First we declare the variables we will be using         Dim newPowerPoint As PowerPoint.Application         Dim activeSlide As PowerPoint.Slide         Dim cht As Excel.ChartObject         Dim trfnum As String 'Variable to obtain Report #         Dim trfname As String 'Variable to obtain Report Title                                   trfnum = Range("K5").Value 'Assign/Obtain Report# from Cell K5              trfname = Range("K4").Value              trfprojnum = Range("K11").Value              trfpartnum = Range("K12").Value              trfsnnum = Range("K13").Value              trfmodelnum = Range("K14").Value                   'Look for existing instance         On Error Resume Next         Set newPowerPoint = GetObject(, "PowerPoint.Application")         On Error GoTo 0          'Let's create a new PowerPoint         If newPowerPoint Is Nothing Then             Set newPowerPoint = New PowerPoint.Application             End If             'Make a presentation in PowerPoint         If newPowerPoint.Presentations.Count = 0 Then             newPowerPoint.Presentations.Add         End If              'Show the PowerPoint         newPowerPoint.Visible = True         ' apply a slide template     newPowerPoint.ActivePresentation.ApplyTemplate "C:\Documents and Settings\myfile\Application Data\Microsoft\Templates\ShortTitle.pot"     regards, Aaron

Hi Jenn, thanks for your response.

i tried with the code you shared, but VBA has prompt me the following error: Presentations (unknown member) : Invalid request. The PowerPoint Frame window does not exist.

It then highlights the code line:    Set pptPres = newPowerPoint.Presentations.Open(file)

What else can i try to resolve this error please?

' src=

Is there a way to insert the graph in a previously saved powerpoint  instead of creating a new powerpoint?

Scratch the last question.

Does anyone know how to automatically insert the chart into the middle of a saved powerpoint instead of the end?

' src=

Thanks for the code; it worked great until I upgraded my Outlook from 2007 to 2010 (did not upgrade PP or Excel, they are still 2007). Now I get a runtime 430 error- Class does not support Automation or does not support expected interface. Any ideas on how to fix? Thanks!  

Hi Kim, Not sure if you are using any ADOs (ActiveX Data Objects) in your code. Please do the following steps: In the VBE (Visual Basic Editor), select Tools > References ... > Microsoft ActiveX Data Objects x.x Library Take the latest version. I have seen many versions of the same. Below link gives you an explanation about why the error occurs: http://makebarcode.com/info/appnote/app_017.html

' src=

I do have one question, from the initial source code : How to modify the code to have the idea but with pictures. no charts So each time the code detect an image on the sheet it will create a new slide?   thanks in advance.  

' src=

I've tried everything I can think of...how is it (with the code presented) that you are getting the words to the right of the charts to go into PowerPoint as a separate object?

It works perfectly with your charts in your spreadsheet, but for the life of me I have not been able to replicate the behavior in my own spreadsheets.

@Chandoo: I am not able to see the updated comments in this page. Is there an issue from my side? Please let me know. Thank you. @Aaron: I believe you are using Office 2007. So, not sure about the extension of the template file. Please check the extension and change the same. Here, in your case, instead of "ShortTitle.pot" it may be "ShortTitle.potx". -DG

  Overall rating     This site has no rating (not enough votes)    

Hi Dolphin, Thanks for your kind response and reminder. it works now!

Glad it worked! Anytime to help 🙂

' src=

Hello. I was trying to modify the supplied code for my purposes but kept hitting snags. As such, I am seeking some help with the following: I have an Excel workbook with various named worksheets and want to copy and paste the print ranges from each worksheet into an existing PowerPoint template using VBA. So, if worksheet “A”s print range is set to print on one page and worksheet “B”s print range is set to print on 3 pages, the PowerPoint presentation should have a total of 4 slides. I could end up with 10 worksheets in total representing 10+ slides needed in the presentation. Am new to VBA and would appreciate the help.

Apologies in my delayed response. Can you provide me the sample file(s), Excel and Powerpoint ones? Let me take a look and try my best.

Thanks for offering to look at the code for me. Where should I send the sample files?

' src=

@Al Refer: http://chandoo.org/forums/topic/posting-a-sample-workbook

Please send it to my email ID, [email protected]

' src=

How can I change the code so it copy and pastes only one specific chart, instead of all the charts?

Hi Ryan,   `'Declare the variable` `Dim ObjChartObject As Excel.ChartObject`   `Set ObjChartObject = Worksheets("WorksheetName").ChartObjects("ChartName")` `ObjChartObject.Chart.ChartArea.Copy` `.` `.` `.` `.` `Continue your code`   Hope this helps.   -DG

' src=

That is a very handy tool.... saved my@$$ 

does anyone know how to modify to always open a new power point .  If ran a second time charts are tacked to the previously created presentation.

Hi, The code that was provided in this example does the same. Please see point 5, you have the entire code. In the code, look for the section - 'Make a presentation in PowerPoint'

Revert back if you are not able to understand.

is there a way to lock out any user input while code is running. if i scroll while charts are moving to the power point the code stops.

Please try the below: 'Type this at the beginning of your code. Application.Interactive = False ... <Your code here> ... <Your code here> ... <Your code here> 'Type this at the end of your code. Application.Interactive = True

Hope this helps.

nope. user input still kills the macro. is there a way to not have screenupdating with powerpoint? or soemthing similar?

it only happens with the transfer from excel to power point. is there a way to have power point come up in a minimized state to at least minimize user interaction?

In the code presented in this example, goto: 'Show the PowerPoint

After the line: newPowerPoint.Visible = True

Type: newPowerPoint.WindowState = ppWindowMinimized

This should keep the PowerPoint application in minimized.

' src=

I have (somewhat) of a reverse situation:

I had to create and access an Excel file from PowerPoint.

The first part (not shown) successfully creates a .CSV file containing several lines of data. E.g.:

     12345,John,8009991212,123 Main Street      58145,Mary,3215551212,666 Mockingbird Lane

... etc. ...

The last part of the macro (shown below) successfully opens the .CSV and Personal.XLS (which contains a macro to format the Excel file), saves as an .XLS in XLS format, then runs the macro "CTI_Format_B" to format the .XLS file (freeze header, autofit columns, etc.).

     'PowerPoint: Open Excel .CSV and save to .XLS, run Macro "FileFormatB"      Dim oXL As Excel.Application  ' Excel Application Object      Dim oWB As Excel.Workbook     ' Excel Workbook Object      Dim FileXLS As String, FileCSV as String      FileCSV = Environ("USERPROFILE") & "\" & "SamplePop.CSV"      FileXLS = Left(FileCSV, Len(FileCSV) - 4) & ".xls"        Set oXL = New Excel.Application      oXL.Visible = True

     Set oWB = oXL.Workbooks.Open(oXL.StartupPath & "\Personal.xls")

     Set oWB = oXL.Workbooks.Open(FileCSV)   'open CSV file

     oWB.SaveAs FileName:=FileXLS, FileFormat:=xlNormal      oXL.Run ("Personal.xls!FileFormatB")      oWB.Save      oXL.Visible = True

The macro "FileFormatB" in Personal.xls contains formatting for the newly saved .XLS:

    'Excel macro to format header, etc.     Range("A1:L1").Select   'format header     With Selection         .Font.Bold = True         .Interior.ColorIndex = 6         .Interior.Pattern = xlSolid         .Font.ColorIndex = 5     End With     Rows("2:2").Select     ActiveWindow.FreezePanes = True     Cells.Select     Cells.EntireColumn.AutoFit

What I would like to do is instead of having a separate macro in Personal.xls to format the file and having to open Personal.xls (which is otherwise invisible when run here), I would like to run the same formatting from the original PowerPoint macro which created the file.

How do I run the formatting from the PowerPoint macro to the opened Excel file?

' src=

I would love to use this, but I get error messages even when I try the code on my file or run the downloaded file.  It says user defined type not defined...Any suggestions?  How do I define: Dim newPowerPoint As PowerPoint.Application

' src=

This is a great post!  

My problem is that I would like to copy all charts on every worksheet in Excel to PowerPoint (2010).

There is one chart per worksheet, with certain cells providing the title and axis label text and, of course, the range of cells that the chart is based upon.

My problem is that I ONLY want to include that data when I paste as an embedded (not linked or picture) object into PowerPoint.

Other data that is not directly related to the chart is included in PowerPoint. This is a problem, as I don't want users of PowerPoint to see that data.

Is there any way to ONLY include the cells that the chart is directly based upon?

' src=

I am using similar code (see below) with Excel 14, Powerpoint 14 and Windows XP. I use this to copy/paste about 100 images from Excel to Powerpoint. Sometimes I get this error: "Shapes(unkown member) : Invalid request. The specified data type is unavailable." I can run the exact same code and it works, then run it again and I get this error. And the error happens in different places of the code execution each time (although always on a PasteSpecial line). Sometimes in first loop, sometimes in 15th loop, etc. Sheets("RoleSummary").Range("RoleSummaryTable").Copy

PPApp.ActiveWindow.View.GotoSlide PPApp.ActivePresentation.Slides.Count

PPSlide.Shapes.PasteSpecial (ppPasteEnhancedMetafile)

' src=

Mike, did you find a solution for this problem? I am having the same!

' src=

Have no solution, but it seems to be less prevalent if you close all other Microsoft programs while it is running, including File Explorer.

' src=

Is there a way to force the program to arrange charts by order from which they are located?  If you cut and paste the first chart and execute the macro, it is now the second chart (based on it's last active postion).  If not by modifying the program, is there a way to change the active arrangements of the charts some other way.  Cheers

' src=

When I tried to run this macro in Excel 2007, I received this error message:

Run-time error '429':

ActiveX component can't create object

I have a range of cells (formatted as tables) that need to be copied from a named worksheet (for this post - the worksheet name is 'Summary') and then pasted (with formatting) into an existing powerpoint presentation on a new slide that will allow me to edit.  Can the code be modified to accomplish this task and get rid of the error?

' src=

Hello, I have a excel workbook with multiple sheets that I want to put into PowerPoint that when runs will loop through all sheets so it can be displayed on a hallway monitor. I would like the PPT to change as the information changes in excel sheet. The sheets are updated at beginning of every shift (x3 shifts). This will allow clients to see this information. I have a no budget limit so I am trying to get it done using excel and PowerPoint. At this point I do not have anything other than data in the sheets but will be adding pictures and charts as needed in the near future. Is it possible to just link the sheets, in current order in the workbook to show the sheet and its contents: data, picture and or chart full screen one sheet per slide?  I have read this entire post and the knowledge here is staggering. Any help with this would be greatly appreciated by all those entering them and printing them out each day and shift. John

' src=

hеy i гead thrоugh thіs anԁ i am neω to asp. nеt... i аm tгying to dеvеlоp my fiгst аpp in іt and this is veгy helpful.

Thank уοu foг the tіme уou spent to write this chеcklіst. your аwesomе.

' src=

Instead of this we can use a paste link option on the paste special... If it is a regular report.

' src=

i want 5 charts in slide How can we do this? Give VBA Code for this. It's very important for me. Plz help

' src=

GREAT POST..

Works like a charm!

' src=

Can you please send me the working file?

I have that particular project being worked on by another GURU at this time. I do however have another project that has to do with dynamic arrays and print macro that is just as mind boggling to me if your interested. I have it posted on may 17th. If your interested I have the working file for it and I would be glad to get help on.

' src=

Nice article and nice Q&A along with nice solution. Here is my question(s)

1. I am preparing sales collaterals. One common requirement I have from engineering team is case studies. Case study data changes from time to time (as projects progress.) Asking engineering team to prepare a new slide on case study everytime a customer presentation is to be made is waste of their time.

2. I have a template for case study in power point. (Basically empty shapes and to be filled with bullted text.) Number of shapes and which shape should contain what text and what data is fixed.

3. I have a excel template to capture the engineering projects. This template is extended version of their project review template. Hence engineering team populates it as part of their review meeting.

4. What I want to do is a. Filter and select the case studies I want to include. b. Run a macro such that using the selected case studies, the shapes in the case study template are populated and a stack of slides for case study is generated.

Question: 1. Is it possible to fill in shapes (mainly text boxes in a powerpoint) slide) using VBA macros? 2. has anyone attempted it and a solution is published? 3. Can anyone help?

Hope you've seen my answer below.

Hope I am not late for you.

I have worked on similar kind of thing, but with PivotTables. When you mention filter I assume it is just a Data > Filter on Excel and not PivotTable filter. You can enter text into shapes (textboxes) using VBA. Below is the code:

Dim SlideTitle As String SlideTitle = "Your Title Goes Here" ActiveSlide.Shapes(1).TextFrame.TextRange.Text = SlideTitle

The shape number, in this case, 1, will change based on which shape (textbox) you want to enter. Note that to get a shape number of the desired textbox can take some time. You try this on a trial and error method.

Let me know if you require further more help on this.

' src=

Hi. I'm trying to figure out how to do the same thing in the tutorial but with pivot tables. I have a problem selecting and copying/pasting to the powerpoint. Every time I try selecting, I get a runtime error 458. Can you please help? Thank you1

Can you let me know where exactly you are having this error? Also, would it be possible to share your code? Please let me know.

I actually solved the issue. I will post the code anyway.

I have a question that's unrelated to this tutorial though. I want to create several pivot tables based on the values from three comboboxes. The comboboxes act like the pivot table filters and also a counter for how many pivot tables to make. I just want to know how I would go about programming this.

Code: Sub CreatePowerPoint() Cells.Select Range("D47").Activate Selection.Columns.AutoFit 'Add a reference to the Microsoft PowerPoint Library by: '1. Go to Tools in the VBA menu '2. Click on Reference '3. Scroll down to Microsoft PowerPoint X.0 Object Library, check the box, and press Okay

'First we declare the variables we will be using Dim newPowerPoint As PowerPoint.Application Dim activeSlide As PowerPoint.Slide Dim cht As Excel.PivotTable

'Look for existing instance On Error Resume Next Set newPowerPoint = GetObject(, "PowerPoint.Application") On Error GoTo 0

'Let's create a new PowerPoint If newPowerPoint Is Nothing Then Set newPowerPoint = New PowerPoint.Application End If 'Make a presentation in PowerPoint If newPowerPoint.Presentations.Count = 0 Then newPowerPoint.Presentations.Add End If

'Show the PowerPoint newPowerPoint.Visible = True

'Loop through each chart in the Excel worksheet and paste them into the PowerPoint For Each cht In ActiveSheet.PivotTables

'Add a new slide where we will paste the chart newPowerPoint.ActivePresentation.Slides.Add newPowerPoint.ActivePresentation.Slides.Count + 1, ppLayoutText newPowerPoint.ActiveWindow.View.GotoSlide newPowerPoint.ActivePresentation.Slides.Count Set activeSlide = newPowerPoint.ActivePresentation.Slides(newPowerPoint.ActivePresentation.Slides.Count)

'Copy the chart and paste it into the PowerPoint as a Metafile Picture

Cells(i, 7).Interior.Color = 44 i = i + 1 cht.PivotSelect "", xlDataAndLabel Selection.Copy activeSlide.Shapes.PasteSpecial(DataType:=ppPasteMetafilePicture).Select

'Set the title of the slide the same as the title of the chart activeSlide.Shapes(1).TextFrame.TextRange.Text = cht.Name

'Adjust the positioning of the Chart on Powerpoint Slide newPowerPoint.ActiveWindow.Selection.ShapeRange.Left = 15 newPowerPoint.ActiveWindow.Selection.ShapeRange.Top = 125

activeSlide.Shapes(2).Width = 200 activeSlide.Shapes(2).Left = 505

AppActivate ("Microsoft PowerPoint") Set activeSlide = Nothing Set newPowerPoint = Nothing

' src=

this is great, but when I open excell file on my Mac, I'm gettint error and presentation cannot be done 🙁

Could you please help me?

Thank you, Andy

Please let me know what the error is. Let's try to fix it.

' src=

This is EXACTLY what I am needed. I have been stumbling on trying to create PPT slides with specific ranges based on user input in Excel. I have a Sub to find the list of ranges to copy but have not been able to get them into PPT. I've tried a few other blogs with not much help. This one works PERFECTLY! Thank you for sharing!

' src=

Hi, I am new to VBA. I am unable to plot more charts. If i add a new tab, it copies the chart however fail to copty the comments. I repleated the code and edited. But, Its shwoing error. Pleas ehelp!!

' src=

It copies just the first chart and then it stops giving the following error - Getting Error code 424: Object not found.

Debug points out fail at this statement -

activeSlide.Shapes.PasteSpecial(DataType:=ppPasteMetafilePicture).Select

Try this: Before the line (CODE=VB)activeSlide.Shapes.PasteSpecial(DataType:=ppPasteMetafilePicture).Select(/CODE)

type the following (CODE=VB)activeSlide.Select(/CODE)

Let me know if this works.

' src=

Having the same issue over here but that didn't work. Any suggestions?

' src=

Same error as above...adding the code doesn't help.

I'm quite a newbie...any suggestions?

' src=

Hi all.. Im working on how to export pivot tablesfrom excel to powerpoint. Any one can help?

Im using this code but in this part Set oPPTShape = oPPTFile.Slides(SlideNum).Shapes("PivotTable6")"it says that pivot table is not part of shapes? Please help.....

Sub PPTableMacro()

Dim strPresPath As String, strExcelFilePath As String, strNewPresPath As String strPresPath = "C:\Users\angeline.descalsota\Desktop\AUTOMATION\TransferFailurePPFile.pptx" strNewPresPath = "C:\Users\angeline.descalsota\Desktop\AUTOMATION\TransferFailurePPFile.pptx"

Dim oPPTShape As DataTable

Set oPPTApp = CreateObject("PowerPoint.Application") oPPTApp.Visible = msoTrue Set oPPTFile = oPPTApp.Presentations.Open(strPresPath) SlideNum = 1 oPPTFile.Slides(SlideNum).Select

Set oPPTShape = oPPTFile.Slides(SlideNum).Shapes("PivotTable6")

Sheets("Sheet1").Activate With oPPTShape.Table .Cell(1, 1).Shape.TextFrame.TextRange.Text = Cells(1, 1).Text .Cell(1, 2).Shape.TextFrame.TextRange.Text = Cells(1, 2).Text .Cell(1, 3).Shape.TextFrame.TextRange.Text = Cells(1, 3).Text .Cell(2, 1).Shape.TextFrame.TextRange.Text = Cells(2, 1).Text .Cell(2, 2).Shape.TextFrame.TextRange.Text = Cells(2, 2).Text .Cell(2, 3).Shape.TextFrame.TextRange.Text = Cells(2, 3).Text End With

oPPTFile.SaveAs strNewPresPath oPPTFile.Close oPPTApp.Quit

Set oPPTShape = Nothing Set oPPTFile = Nothing Set oPPTApp = Nothing

MsgBox "Presentation Created", vbOKOnly + vbInformation End Sub

' src=

Hi! Works like a charm! However, I'd like to make a small adjustment and need some help. My goal is to use the same code but clicking the chart itself instead of pushing a button. The point is to only export the chart(s) selected by clicking them one at a time (each slide contains alot of charts).

This part should probably be deleted if possible. I would be annoying to have to switch windows after each click: 'Show the PowerPoint newPowerPoint.Visible = True

I know nothing of VBA but learned some basic programming about 15 years ago so I understand to broad strokes. Please help 🙂

' src=

I did a small bit of playing around and found that there is no simple solution to your problem given Microsoft’s limited capability with their software. The only solution I have found so far that works in a way of how you want it is the following.

1) Each chart cannot be an object on a sheet it needs to be in a chart by itself.

2) Copy and paste the following code into each charts code (rename the variable if you desire)

Dim ClassMod As New ChartEvents

Private Sub Chart_MouseDown(ByVal Button As Long, ByVal Shift As Long, ByVal x As Long, ByVal y As Long) Set ClassMod.Excht = ActiveChart End Sub

3) Create a class named ChartEvents (unless you are going to change the variables) and then copy and paste the following modified code (Originally the code Drew posted)

Public WithEvents Excht As Chart

Private Sub Excht_MouseDown(ByVal Button As Long, ByVal Shift As Long, ByVal x As Long, ByVal y As Long)

'Add a reference to the Microsoft PowerPoint Library by: '1. Go to Tools in the VBA menu '2. Click on Reference '3. Scroll down to Microsoft PowerPoint X.0 Object Library, check the box, and press Okay

'First we declare the variables we will be using Dim newPowerPoint As PowerPoint.Application Dim activeSlide As PowerPoint.Slide Dim cht As Application

'Add a new slide where we will paste the chart newPowerPoint.ActivePresentation.Slides.Add newPowerPoint.ActivePresentation.Slides.Count + 1, ppLayoutBlank newPowerPoint.ActiveWindow.View.GotoSlide newPowerPoint.ActivePresentation.Slides.Count Set activeSlide = newPowerPoint.ActivePresentation.Slides(newPowerPoint.ActivePresentation.Slides.Count)

'Copy the chart and paste it into the PowerPoint as a Metafile Picture ActiveChart.ChartArea.Copy activeSlide.Shapes.PasteSpecial(DataType:=ppPasteMetafilePicture).Select

'Adjust the positioning of the Chart on Powerpoint Slide newPowerPoint.ActiveWindow.Selection.ShapeRange.Left = 15 newPowerPoint.ActiveWindow.Selection.ShapeRange.Top = 100

activeSlide.Shapes(1).Width = 500 activeSlide.Shapes(1).Left = 115

AppActivate ("Microsoft PowerPoint") Set activeSlide = Nothing Set newPowerPoint = Nothing End Sub

4) Make sure to save your workbook as a macro enabled excel file or else you will have to do it all over again.

When you change your chart and then click on the chart the first time it will create a new presentation with the chart centered for the most part (fine tune the size and location as desired). Presently this is the only way I have discovered to accomplish this. If there was a way to create a custom handle for objects on a excel sheet this would have been easier.

I hope this helps. Blank

' src=

Very interesting approach. This article is old but looks interesting to me even today. I envision to create dashboards automatically in PowerPoint using this method and getting the data from Excel but with one of our PowerPoint templates.

Julian @ SlideModel

' src=

This really a very nice post and saved me a lot of time.

Thanksss sooo much guys for posting this!!.

I have 32 graphs, to be pasted on 16 slides ( 2 slide each) and some static introductory slides. in total 19 slides.

Please help me on this one.

Thanks in advance Vicky

' src=

hi, i having problems with callout text , if I try to add more text this doesnt take in account, how you deal with this or wich is the trick?

' src=

Wonderfull trick, will save me a lot of effort 🙂

I would like to name the generated ppt depending on the chart title. can anybody tell me how?

@Wouter: Check if the below code works for you:

[code] If Worksheets("Sheet1").ChartObjects(1).Chart.HasTitle Then strChartTitle = Worksheets("Sheet1").ChartObjects(1).Chart.ChartTitle.Text Else strChartTitle = "My Chart Title" End If [/code]

Change the name of the Sheet where you have the chart. Let me know if this works.

hm I want to change the name of the PPT not the sheet, will this do the trick?

Please see below: Assuming you have Test folder in C Drive,

For 97-2003 PowerPoint file, use newPowerPoint.ActivePresentation.SaveAs "C:\Test\Test.ppt"

For 2007 and above PowerPoint file, use newPowerPoint.ActivePresentation.SaveAs "C:\Test\Test.pptx"

' src=

i want this method in ms access vba can u help me Please?

Thanks Drew for the code but i am getting error at line "Dim newPowerPoint As PowerPoint.Application". Error box showing message as Complie error Useer-defined type not defined. Can you tell me whats the problem ?

I may be late. Probably you may need to add the reference of Microsoft PowerPoint XX.0 (whichever version you are having). To add, do the following: In Visual Basic Editor, Click on Tools > References then look for Microsoft PowerPoint under the list in Available References. Hope this helps.

Regards, DG

' src=

Thanks for your work. Just upgraded from 2007 to 2010 at the office and the macros did not work. Turns out copying and pasting in VBA IS different between 2007 and 2010. I was pasting both tables first copied as pictures in excel and then charts copied to PP. File had about 50 images, and was blowing up from 2M to 13M! This gave me some insight into how to address this. The same copy and paste command does not work for copying table ranges and chart images. Furthermore, your pastespecial command for pasting into PP enabled me to research other data types and find one that got the file size back down.

Thanks, Steve

' src=

I have a excel sheet named "Graph" containing charts in matrix form 30 rows and 5 columns(ie 5 charts in first row, 5 charts in 2nd row and so on). I want to make a powerpoint with 9 charts in each slide(5 charts from first row and remaining 4 charts from 2nd row). Somebody please help me.

' src=

how to get this pattern using macro vb code please help me with code,thanks in advance 1 12 123 1234 12345 123456 12345 1234 123 12 1

Sub Make_No_Pyramid() Dim MaxNo Dim i As Integer, j As Integer

MaxNo = InputBox("What is the Maximum Number", "What is teh Maximum Number")

Range("A:A").ClearContents For i = 1 To MaxNo - 1 For j = i To MaxNo - 1 Cells(j, 1) = Cells(j, 1).Text & CStr(i) Cells((2 * MaxNo) - j, 1) = Cells((2 * MaxNo) - j, 1).Text & CStr(i) Next j Next i For i = 1 To MaxNo Cells(MaxNo, 1) = Cells(MaxNo, 1).Text & CStr(i) Next i Columns("A:A").HorizontalAlignment = xlLeft

' src=

My excel charts are generated when I select respective countries from a drop-down list in my data sheet. Is there a way I can incorporate this into the dashboard, i.e., create a button for country and when I select "Singapore", all charts are showing Singapore data and I can export to PPT?

Similarly, how to create the button for month? i.e., select "Jan 15" and charts is generated with Jan 15 as the last data point?

Appreciate all help/answers! 🙂

Thanks, Grace

' src=

If possible I would suggest using slicers to change the country selection and then a mcaro to control the slicer.

After I migrated to Office 2013 the code has been having trouble due to Powor Point freezing at some point while pasting charts. I've tried using Application.Wait in multiple parts of the code to allow Power Point enough time to copy and paste. However it is still crashing. Does any one have this same issue? How can I fix it?

' src=

using Drew's post in excel 2013 ... and getting error 429 the GetObject is failed line ... 'Look for existing instance On Error Resume Next Set newPowerPoint = GetObject(, "PowerPoint.Application") On Error GoTo 0

so, launched PP manually and got around the 429.

Now getting 424 error here : 'Copy the chart and paste it into the PowerPoint as a Metafile Picture cht.Select ActiveChart.ChartArea.Copy activeSlide.Shapes.PasteSpecial(DataType:=ppPasteMetafilePicture).Select

' src=

I got this to work and it is GREAT but the text boxes for the powerpoint are linked directly to certain cells in excel. Is there a way to add the text to the slides in an easier manner? I want to create a template that any user could add into an excel workbook and it would add text located next to the charts no matter how many slides there were if there is text next to the chart. Or could someone point me in the right direction or website to figure out how to do this? Thank you in advance.

@lonestardave: If you have a textbox/textframe on the slide, then the below code should work (if it is PowerPoint 2007/2010): [CODE]ActiveSlide.Shapes(2).TextFrame.TextRange.Text = "Test line 1" & vbcr & "Test line 2"[/CODE]

The number 2 in Shapes(2) can change based on the number of objects you placed in the slide. The number 1 can/will be the header of the slide and post that how many ever textboxes/frames you have. You have to check this on trial and error basis.

[CODE=VB]ActiveSlide.Shapes(2).TextFrame.TextRange.Text = "Test line 1" & vbcr & "Test line 2"[/CODE]

' src=

This has been incredibly useful, I have implemented this in many powerpoints and saved roughly 4 hours a month i reckon. I am not quite done yet though, im using excel 2003 and when i try to resize the pasted image via :

mySlide.Shapes.PasteSpecial DataType:=ppPasteEnhancedMetafile Set myShapeRange = mySlide.Shapes(mySlide.Shapes.Count) 'Set position: myShapeRange.Left = 234 myShapeRange.Top = 186

, I don't get an error or anything but its just that controlling height and width don't work properly, this stops me from formatting the chart sizes. Any clue to whats going on ? solutions?

' src=

I have Office 2010 and have been integrating to TFS via Excel and subsequently generating Powerpoints through Excel for several months now, using VBA. However, i was upgraded to Project 2013 at the end of January and the integration between both TFS and Powerpoint from within Excel were broken. I found a registry key that made Excel think it was 2013 so it was looking for the wrong libraries to connect with TFS. Removing this key solved the TFS issue. However, I still have not figured out how to solve the error that prevents me from generating Powerpoints. I receive the following error

Runtime error '-2147319779 (8002801d)'

Automation error Library not registered

Any help or direction with this would be much appreciated.

Thank you, Chuck

' src=

Hi all, This is JUST what I needed and was looking for!!

However, I am getting the following -

Run-time error: '2147188160 (80048240)': Application (unknown member) : Invalid request. There is no active presentation.

What am I doing wrong?

' src=

I have managed to make use of this wonderful aspect of excel VBA.. If you still need my help I am available today...

awaiting for your response...lets do it with close interaction.. Amjad

Hi, Anybody whose query is still pending, please let me know... I have managed to make use of this wonderful aspect of excel VBA.. If you still need my help I am available today...

' src=

I want to get images in the slide rather charts what changes should I do?

' src=

I am getting the following error when I am trying to run this code

Compile Error: User Type Not Defined

Can anyone help with this?

' src=

How do I make the macro paste each chart on an specific slide?

I want to get the images rather charts in the slides. What changes should I make in the vba code?

' src=

Hi Chandoo, Can we automate alignment of data labels for any charts ?

@Chintu If you setup a chart exactly how you want it Then save that chart as a template

You can apply that template to future charts and get the same styles, layout, alignments, colors etc

' src=

I have a vba button on sheet 1 with charts on sheet 16. I want to click the button on sheet 1 to run the charts on sheet 16. Currently, you can only run the code if you are on the active sheet.

Ron (ref your post 08/17/2016),

I don't understand what "run the charts" means? Can you enlighten me please?

The code written only works if you are on that active sheet. I want to click a macro button to activate the code. A button will be placed on sheet 1 and the charts will be a sheet 16. I want people to click the button an create a powerpoint with the charts on sheet 16.

' src=

Simply change the following piece:

'Loop through each chart in the Excel worksheet and paste them into the PowerPoint For Each cht In ActiveSheet.ChartObjects

'Loop through each chart in the Excel worksheet and paste them into the PowerPoint Sheet16.Select For Each cht In Sheet16.ChartObjects

' src=

Can anybody help to figure out inserting all charts into ONE slide instead one chart per one slide?

' src=

Hi all, How to make to multiple images into multiple slides using VBA? For example, the images(jpg) and ppt file are saved in same folder. "Run macro" Image#1 is into Slide#1 Image#2 is into Slide#2 Image#3 is into Slide#3 . . . Image position and size are Left:=20, Top:=80 Width:=500, Height:=200

Can you help me please???

I want to change the path from "FileName:="C:\ ~ to current path because ppt (including images file) file path is not static.

And the images (wave_prfile and pattern.jpg) are on active slide(ppt) when run below macro.

If i want to import other images on other slides(ppt), how should i change below macro.

Please help me!

Sub InsertImage()

ActiveWindow.Selection.SlideRange.Shapes.AddPicture( _ FileName:="C:\Temp\PPT_REPORT_MACRO\wave_profile.jpg", _ LinkToFile:=msoFalse, _ SaveWithDocument:=msoTrue, Left:=15, Top:=88, _ Width:=690, Height:=190).Select

ActiveWindow.Selection.SlideRange.Shapes.AddPicture( _ FileName:="C:\Temp\PPT_REPORT_MACRO\wave_pattern.jpg", _ LinkToFile:=msoFalse, _ SaveWithDocument:=msoTrue, Left:=15, Top:=282, _ Width:=690, Height:=220).Select

Can you please ask the question in the Chandoo.org Forums, http://forum.chandoo.org/

Please attach a sample file to simplify the response

Thanks for your comment. I already join in Chandoo.org Forums. However, I don't know how to post on the Forums.

Please let us know. Thanks a lot.

Goto the Forums and Login Select the Forum most appropriate to your question Select Post New Thread Type in a Subject/Title and complete the body of the thread Add a file is a Button at the Bottom of the thread

Thanks and Noted. Happy Christmas!

' src=

i have number of charts in an excel, i need to select by there title, is it possible

A Technique to do this is discussed here: http://chandoo.org/wp/2009/05/19/dynamic-charts-in-excel/

' src=

I have the code working almost to satisfaction currently but i'd like to be able to remove the chart title and set it as the slide title rather that have it duplicated on chart and slide. How would i go about that?

Sub CreatePowerPoint()

'First we declare the variables we will be using Dim newPowerPoint As PowerPoint.Application Dim activeSlide As PowerPoint.Slide Dim cht As Excel.ChartObject Dim DefaultTemplate As Object

'Open the default template Set DefaultTemplate = CreateObject("powerpoint.application") DefaultTemplate.Presentations.Open Filename:="C:\Users\cody.jeffries\Documents\Custom Office Templates\xxx.pptx" DefaultTemplate.Visible = True

'Let's create a new PowerPoint 'If newPowerPoint Is Nothing Then 'Set newPowerPoint = New PowerPoint.Application 'End If

'Make a presentation in PowerPoint 'If newPowerPoint.Presentations.Count = 0 Then 'newPowerPoint.Presentations.Add 'End If

'Show the PowerPoint 'newPowerPoint.Visible = True

'Add a new slide where we will paste the chart newPowerPoint.ActivePresentation.Slides.Add newPowerPoint.ActivePresentation.Slides.Count + 1, ppLayoutTitleOnly newPowerPoint.ActiveWindow.View.GotoSlide newPowerPoint.ActivePresentation.Slides.Count Set activeSlide = newPowerPoint.ActivePresentation.Slides(newPowerPoint.ActivePresentation.Slides.Count)

'Copy the chart and paste it into the PowerPoint as a Metafile Picture cht.Select ActiveChart.ChartArea.Copy activeSlide.Shapes.PasteSpecial(DataType:=ppPasteMetafilePicture).Select

'Set the title of the slide the same as the title of the chart 'activeSlide.Shapes(1).TextFrame.TextRange.Text = cht.Chart.ChartTitle.Text

'Adjust the positioning of the Chart on Powerpoint Slide 'newPowerPoint.ActiveWindow.Selection.ShapeRange.Left = 25 activeSlide.Shapes(2).Width = 800 'activeSlide.Shapes(3).Left = 505 newPowerPoint.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True newPowerPoint.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True newPowerPoint.ActiveWindow.Selection.ShapeRange.Top = 90

Set activeSlide = Nothing Set newPowerPoint = Nothing

' src=

How can I amend this code so that it points to a specific worksheet to be exported, rather than just the active sheet?

I want to create a dashboard on a separate worksheet with an "export to PowerPoint" button at present the macro requires the exact worksheet to be selected...

Many thanks

' src=

Hi all, Is there anyway of modifying the example worksheet code so that it captures print ranges from different worksheets instead of having to list each line you want captured manually.

If the code variation that allows you to say import to slide 1 or slide 2 can also be shared then that would be appreciated.

I'm also not looking to export graphs just text entries so if the code can be simplified as a result then even better.

Thanks in advance for any help.

' src=

Hi, is there a way to combine pivot charts from multiple workbooks into one sheet and then automatically create a powerpoint from it? Or let's just say that I have pivot table in different workbook and I want to combine them all to make one powerpoint presentation. Any help will be greatly appreciated. Thanks!

' src=

Hi, probably. I would start with using EXCEL PowerQuery to combine the pivot charts from multiple workbooks into one sheet.

' src=

Is there any way to simplify VBA programming?

What I'd like to do is create a powerpoint macro that re-creates a slide graphic (rather than copy-pasting it from a previous presentation). Instead of programming each individual part of the slide graphic, can I "apply" the formatting of one slide to another slide? I'm thinking there must be a way for me to reference another slide in creating a new slide...

' src=

I realize this is an old post, but I'm hoping someone can still help me.

I am using Excel and PowerPoint 2016 -64 bit

I have used this code with tweeks to size and position the charts. Everything works great on my computer. When I switch to another computer using the exact same Excel and PowerPoint versions, the charts are sized and positioned differently. I opened the PowerPoint presentation made from the second computer on my computer and the charts are the same wrong size in which they were created. I leave that presentation open, run the macro from excel and the charts size correctly.

Any ideas would be greatly appreciated.

Hi, I would start by comparing the Advanced System settings for Performance for each computer then compare the graphic 'card' and monitor settings. The problem sounds similar to HTML scripting where the positioning can be coded relative to the display environment.

Hi Drew, Thank you for publishing this undocumented "slides.add" method. Makes you wonder how many other undocumented features there are. Kind of like the 'easter eggs' of old. Thanks again.

' src=

Your code was very helpful. Just wanted to know if it's possible to create a ppt with a predefined template and not just plain white slides. I have my own template, if you can share the sample code that would be great.

' src=

Is there a workaround to the error DavidLim commented on 8/2011 "however, if a chart (or combo grouped-charts) is large, the VBA will not run.

error box: “Run-time error -2147418113 (8000ffff)’: Method ‘Copy’ of object ‘ChartArea’ failed”"

I'm having this problem. Wonder if it's because the chart I'm trying to export was created in Excel 2007 (Zimmerman in 2010 now). Code works fine with brand new chart.

Couple of other questions: - is there a way to 'set focus' on the pasted chart to do something like resize so I don't have to figure out which shape number it is (ex. know that it is the 3rd shape and then use shape(3).top) - how can u name a chart and then ref in code regardless on what sheet it's on

' src=

"how can u name a chart and then ref in code regardless on what sheet it's on" This macro will name the selected shape: Sub NAMEIT() ActiveWindow.Selection.ShapeRange(1).Name = "Shape_name_1" End Sub

This will loop through each slide and check for that shape name: Set opres = Presentations.Open(fxname, False, False, True) opres.Windows(1).Activate

'Looping through each slide

For i = 1 To opres.Slides.Count 'ActivePresentation.Slides.Count For Each oSH In opres.Slides(i).Shapes

If oSH.Name =

For i = 1 To opres.Slides.Count 'ActivePresentation.Slides.Count For Each oSH In opres.Slides(i).Shapes If oSH.Name = "Shape_name_1" then 'Do whatever you need to the shape. end if Next Next i

' src=

Great help! Thanks!

[…] http://chandoo.org/wp/2011/08/03/create-powerpoint-presentations-using-excel-vba/ […]

' src=

The code presented in this tutorial is great. Was able to adapt to exporting Excel ranges in no time. Thanks for getting this out there!

' src=

Id like to do this same concept but instead of charts, I'd like pictures and next to it words.

Any thoughts?

[…] Create PowerPoint Presentations Automatically using. – You've been there before. It's almost 5:00, and you are going crazy trying to finish the presentation due for a monthly performance meeting the next morning. […]

[…] here is some extra help on Automating Powerpoint with VBA and […]

' src=

This is awesome. My question is once this ppt is created how can I save this in user desktop/ drives and then next time if my excel is refreshed , macro only refreshes the ppt rather that creating a new one again

' src=

Thank you so much Drew for writing this insightful article. Being a PowerPoint template designer, VBA is not my thing, but your step by step instructions made it easy to work. Thank again!

Sam @ Slidehelper

' src=

I am trying to get this code working with Microsoft Excel 2016. I have updated the reference to new PPT object Library. The code creates a powerpoint but, crashes at AppActivate ("Microsoft PowerPoint") in Sub BuildPPT().

' src=

I would like to create a PPT, possibly just one slide where a block of text can slowly be changed one character at a time under the control of a VBA program. Sometimes a character is inserted and sometimes one character is replaced by another. Is this something I can do with VBA and PPT?

' src=

Thanks Drew. This article is old but interesting nonetheless. Having the ability to create PowerPoint presentation automatically using VBA has saved us countless hours in manually creating slides for frequently updated reports and dashboards.

' src=

Hi Chandoo, really love this VBA code you did 🙂

I need to create something similar like the example at the bottom: https://www.presentationpoint.com/blog/automating-powerpoint-from-excel/

Am wondering if you have a VBA for this, because the above link is a paid plug in, and i am just an intern trying to impress my boss hahaha

' src=

Great job here...What is frustrating to me is that there is no way, as far as I know, to do the same with Word documents. Word has so many options (forms, etc.) and it seems that one should be able to do the same with Word. I know that Word headings can be automatically converted but not images, forms, etc. (as far as I know). Is anyone aware of any VBA routine that will allow us folks that like to use Word in document generation to do a similar thing that has been demonstrated here???? Thanks!!!

@York Have a read of : https://social.msdn.microsoft.com/Forums/office/en-US/aa1ae70a-4a70-467f-afea-318de2281f71/using-vba-to-capture-word-documents-and-paste-to-powerpoint?forum=officegeneral

' src=

Why you just don't create the image linked with you excel table?. So any changes in the excel table will make the powerpoint chart update.

' src=

Please make a VB script in excel paid basis

' src=

Really Helpful content Chandoo, I also have some of excel tools developed at my end. Can be really helpful for data analysts and process engineers. Please let me know how can I contribute my bit.

' src=

Thanks Drew!

' src=

No sé como resolver en powerpoint error en presentación Application (unknown member): Invalid request. There is no currently active document window. desde un boton en una diapositiva quiero que vaya a la diapositiva 2 y abra formulario.

Sub acceso_inicial_Click()

Application.ActiveWindow.View.GotoSlide 2

UserForm1.Show End Sub

Leave a Reply

Name (required)

Mail (will not be published) (required)

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Notify me of when new comments are posted via e-mail

Get FREE Excel & Power-BI Newsletter

One email per week with Excel and Power BI goodness. Join 100,000+ others and get it free. 

Get Started

  • Excel Basics
  • Advanced Excel
  • 100+ Formulas
  • Free Crash Course
  • Pivot Tables

Online Classes

  • Excel School
  • VBA Classes
  • Power BI Classes
  • 50 ways to analyze data
  • Mini Courses
  • Welcome Message
  • Forum & Community
  • 20+ Excel Templates
  • 200+ Dashboards
  • 40+ VBA Code samples
  • Ebooks & More

© All rights reserved.

EasyTweaks.com

How to create and add slides to PowerPoint presentations with VBA?

A couple days ago, a reader asked about there is a way to automate creation of PowerPoint presentations from scratch and then quickly add slides to that existing presentation. I though that script might be highly in the list of the most useful PowerPoint Macros. 

As we indicated in the past, PowerPoint doesn’t include a Macro Recorder (that’s unlike Excel and Word, which both have built in recorders for Macro). Therefore, we are left with good old Visual Basic for Application that we can use to create simple Macros to automate PowerPoint. There are further alternatives for PowerPoint Automation, but those goes beyond the scope of this tutorial.

In today’s short tutorial, we’ll go over three different use cases:

  • New presentation creation (blank or using a template)
  • Add slides to an existing presentation.
  • A mix of the two above mentioned cases (Create from scratch and slides addition)

Let’s get started.

Look at the Ribbon. If you don’t see the a Developer entry in the menu, before start your coding you’ll need to enable the developer tab.

After you make the Developer menu visible your Ribbon, go ahead and hit on Developer , then hit on the Visual Basic button (or simply go ahead and hit Alt+F11) to open the Visual Basic IDE.

VBA to Create PowerPoint Presentation

  • In the VB Editor, right click on VBAProject and hit Insert .
  • Select Module .
  • Paste the following code in the newly create module.
  • Hit File and then Save.
  • To Run your code, hit Run and then pick Run Sub/User Form (or simply F5).
  • Close the VB editor.

VBA to insert slides

  • In the VB Editor, right click on VBAProject and hit Insert.
  • Select Module

Add slides at the end of the presentation

In order to insert a new blank slide at the last position in your presentation, use the following VBA code:

Macro to setup a new presentation and add slides

That would be just mixing up the two snippets outlined above.

Generate a PowerPoint Presentation from Excel

Last case is that you would like to create a PowerPoint presentation right from an Excel spreadsheet. You can employ the same technique from Word and other Microsoft 365 Applications.

  • Link the Spreadsheet to the PowerPoint Data Model (from Tools>>References)
  • Insert a button unto your Excel spreadsheet (Developer >> Insert and then pick a Command Button).
  • Insert the VBA code below into your Spreadsheet VBA Project (directly into the Sheet or into a VBA Module)
  • Modify the script as required.
  • Run (hit F5) and test the outcome.

Supercharging PowerPoint interactive presentations with VBA (Part 1)

  • Written by: Jamie Garroch
  • Categories: PowerPoint productivity , Presentation technology
  • Comments: 10

powerpoint presentation vba code

PowerPoint has evolved into an app which is the Swiss Army knife of content creation, not only for presentations, but also printed collateral, videos and even interactive presentations.

Imagine you have to use a file containing all the slides you could possibly present to your audience knowing that you will only present a small subset of them at any one time. That’s where interactive presentations can be a powerful addition to your presentation arsenal. It’s a bit like visiting a website and only clicking on the pages you’re interested in as opposed to visiting every single page. Interactive presentations provide you with the ability to quickly react to your audience by jumping around your content live instead of having to say: “I’ll come to that later” and then forgetting!

The interactivity element provides the presenter with the ability to click on objects on their slide which then takes them to a specific location in the presentation.

Interactive presentations: The basics

I’ll use a basic example like the slide below to show you how to add interactivity to your presentation. There is a menu on the left-hand side of the slide which we’ve built with various shapes. Let’s say you want use this to give the presenter the ability to jump to either the next or previous slide:

basic un-hyperlinked slide

The first thing you need to do is select the object you want to make interactive:

BrightCarbon VBA supercharged interactive presentation screenshot 1b

You then need to link it to another slide. The functionality required to achieve the linking is simple and utilises a long-standing feature of PowerPoint called Actions . You can find this feature in the Insert tab of the PowerPoint ribbon:

PowerPoint ribbon with Action tab selected

When you click the Action button, you get a plethora of options in two tabs as you can see:

BrightCarbon VBA supercharged interactive presentation screenshot 2b

These tabs allow you to set links for either or both of two mouse actions, Mouse Click and Mouse Over (or ‘mouse hover’).

The one you’ll probably use the most is Mouse Click and you can use the Hyperlink to dropdown to link to one of several built-in navigation options:

BrightCarbon VBA supercharged interactive presentation screenshot 3

Again, the ones you’ll probably use when creating interactive presentations are Next Slide , Previous Slide and Slide… where you can choose a specific slide to link to.

Once you’ve added the action to your object you can click on it in slide show mode and it will take you to whatever slide or content you chose to link to.

The Animation Challenge

One aspect of creating interactive presentations is that if you combine the above action technique with animation, the animations are not reset automatically when you return to a slide that has already been presented. This might be an issue if you want to either replay the animation sequence or if you’ve used animation triggers to show and hide your menu. In the later case, the menu would remain on screen when you return to a previously presented slide and that means the presenter must spend time hiding it again.

So, what can you do about this?

Technique 1: Duplicate Slide

There is a native non-VBA technique you can use which is to create a duplicate of the slide without animations and set it to automatically transition to the next slide on zero seconds as seen in the top-right of the ribbon here:

BrightCarbon VBA supercharged interactive presentation screenshot 4

You then change the action hyperlink to point to this duplicate slide instead of the one with the animations. This forces the animation on the slide you want to show to reset.

Technique 2: VBA Magic

The challenge with the above technique is that you must now maintain two copies of every slide in the presentation and secondly, remember to set the links to the auto-transition slide, not the slide you will present. This can make your interactive presentations into much more cumbersome files with more slides than is really necessary, subsequently making them more difficult to maintain.

You can avoid having to do this by adding a couple of VBA macros to our project. If you’re not familiar with how to add VBA to your presentation, have a look at our blog article showing you how to do it.

You’re going to create two VBA macros to go to the next slide and previous slide, both of which will reset the animations on the target slide. The full code is available at the end of this article.

Here is the VBA code for the next slide macro:

Once you have this code in our project you can go back to the Insert/Action dialog and change the mouse click action to run our custom macro:

BrightCarbon VBA supercharged interactive presentation screenshot 5

How does it work?

The opening line of the macro passes the shape you clicked on to the macro:

Public Sub NextSlide(ByRef oShp As Shape)

This allows us to determine which slide you’re on by setting a reference to the shape’s parent object, which is the slide:

Set oSld = oShp.Parent

You can now find out what the slide index is for this slide and increment it by one:

lIdx = oSld.SlideIndex + 1

You need to handle what happens if you’re on the last slide and you’ve chosen to link back to the first slide in that case:

If lIdx = ActivePresentation.Slides.Count Then lIdx = 1

The last step is to actually tell PowerPoint to go to this slide:

SlideShowWindows(1).View.GotoSlide lIdx, msoTrue

The magic part of this is the tiny msoTrue on the end of the line. The GotoSlide method (think of a method as an action verb) takes two arguments. The first is the slide index you want to go to and the second is a boolean option to tell PowerPoint to reset the animation for that slide, or not.

Now when you click any object that has this macro assigned to the Mouse Click action, the slide show will go to that slide and reset the animations.

BrightCarbon PowerPoint Trust Center Settings for Macros

Now that you know how to use VBA when creating interactive presentations, check out my post on restoring default slide master layouts with VBA. or discover our Click-and-Explore service to find out how we can help create your next beautifully-designed interactive presentation.

Full code for Next, Previous and Reset Animation macros

You can copy and paste the full code from below into your VBA project. The PreviousSlide macro works just like the NextSlide one with a small adjustment to loop to the last slide if you’re on the first slide.

There is also a simpler ResetCurrentSlide macro which you can assign to any shape on your slide or slide master or layout which just resets the animations for the current slide.

Navigating to a specific slide

This concept can be taken further should you wish to navigate to a specific numbered slide. You need a way to pass the number of the slide you want to navigate to into the macro. A nice and easy way to do this is to use the name of the shape you assign the click action to. Open the Selection Pane by pressing the very secret shortcut Alt+F10 (or clicking the Home tab followed by Arrange / Selection Pane ) and change the name of your clickable shape to “5” for example. Now link that shape to the macro below:

Got something extra you’d like PowerPoint to do?

Check out our PowerPoint automation service which provides you with a custom solution to your specific needs.

powerpoint presentation vba code

Jamie Garroch

Principal technical consultant, related articles, how to consistently brand graphs and charts across microsoft office.

  • PowerPoint design / PowerPoint productivity
  • Comments: 1

How do you make sure that your graphs and charts have consistent branding across Excel, PowerPoint and Word? Learn how to create and use custom templates that support your brand identity across Microsoft Office.

powerpoint presentation vba code

Changes to VBA Macro Security in Microsoft 365

  • Presentation technology / Industry insights
  • Comments: 2

You can do some really cool things in Microsoft Office with just a few lines of Visual Basic for Applications (VBA) - from creating your own custom formula in Excel to correcting branded content in PowerPoint to merging address data for a mail campaign in Word. And sometimes you need to share that VBA solution with colleagues and clients, via the Internet. A change that Microsoft rolled out at the end of March 2022 tweaks the process required by Windows users to gain access to this active content.

powerpoint presentation vba code

Protecting your prized PowerPoint content

  • PowerPoint productivity / Presentation technology

Our comprehensive guide to password protecting PowerPoint files so your precious presentations stay just they you made them!

Best methods you have shared here to make interactive presentation in Power Point.

Thanks Aira!

You have come forward with the top methods to make interactive presentations with Power Point.

Thank you SOOO much for this — what a wonderful resource. Extremely well explained all the way through.

Question: is there a similar way to what you’ve described above that would allow me to target a specific slide number. I can see that i could do the math (+ or – X number of slides), but then i’d need a new macro for every slide. If there are any solutions for this, i would greatly appreciate it.

Hi Daniel. Glad it’s helpful for you. I think the easiest way to achieve this would be to use the name of the object and pass it to the navigation macro. For example, if you create a shape on a slide, change it’s name to “5” in the Selection Pane (Alt+F10) and then link it to the GoToSlide macro above then that would do what you want.

hii, thanks for that. one question, in the end, can I convert my ppt to pdf or another format in a way that the content will be no edible ?

Thanks for all the great advice. I’m trying to create a PowerPoint where text entered on the first slide populates text boxes in later slides. Any suggestions?

Hi sufyan and thank you for the question. You can convert any PowerPoint file to a PDF regardless of the source file format e.g. a pptx or a code-enabled pptm, even a ppsx/ppsm slide show. But, any VBA code will be stripped out as Adobe doesn’t support it and hence the functionality provided by that code will be lost. I hope that helps.

Thanks for all the great advice. I’m trying to create a PowerPoint where text entered on the first slide populates text boxes in later slides. Any suggestions?

Hi Kieran. You could do that with VBA. One decision to be made upfront is what triggers the update. It’s possible to detect when users are editing text but that’s a very involved development. Alternatively, if it’s just you using the solution then a simple macro could work which you manually call using Alt+F8. The simple example below will copy the text from the selected object to any other shape with the same name (use Alt+F10 to open the Selection pane to name objects) that it finds in the presentation:

Sub CopyTextFromSelectionToSameNamedObjects() Dim oShpSrc As Shape, oShpTgt As Shape Dim strText As String Dim oSld As Slide

On Error Resume Next ‘ Error handling off!

Set oShpSrc = ActiveWindow.Selection.ShapeRange(1)

If oShpSrc Is Nothing Then Exit Sub

If oShpSrc.HasTextFrame Then strText = oShpSrc.TextFrame.TextRange.Text Else Exit Sub End If

For Each oSld In ActivePresentation.Slides For Each oShpTgt In oSld.Shapes If Not oShpSrc Is oShpTgt Then If UCase(oShpTgt.Name) = UCase(oShpSrc.Name) Then If oShpTgt.HasTextFrame Then oShpTgt.TextFrame.TextRange.Text = strText End If End If Next Next End Sub

If you’d like us to develop this further for you, please use our Contact form.

Leave a Reply Cancel reply

Save my name and email in this browser for the next time I comment.

Join the BrightCarbon mailing list for monthly invites and resources

First of all the deck looks great, once again you guys have done an outstanding job. Second, I’d like to comment on the quality of the training provided by your colleagues - quite simply it was exceptional. I have spoken to the whole team and that view is unanimous. Please pass this on. James Bagan MyLife Digital

powerpoint presentation vba code

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Presentations object (PowerPoint)

  • 7 contributors

A collection of all the Presentation objects in Microsoft PowerPoint. Each Presentation object represents a presentation that's currently open in PowerPoint.

The Presentations collection doesn't include open add-ins, which are a special kind of hidden presentation. You can, however, return a single open add-in if you know its file name. For example Presentations("oscar.ppa") will return the open add-in named "Oscar.ppa" as a Presentation object. However, it is recommended that the AddIns collection be used to return open add-ins.

If your Visual Studio solution includes the Microsoft.Office.Interop.PowerPoint reference, this collection maps to the following types:

  • Microsoft.Office.Interop.PowerPoint.Presentations.GetEnumerator (to enumerate the Presentation objects.)

Use the Presentations property to return the Presentations collection. Use the Add method to create a new presentation and add it to the collection. The following example creates a new presentation, adds a slide to the presentation, and then saves the presentation.

Use Presentations ( index ), where index is the presentation's name or index number, to return a single Presentation object. The following example prints presentation one.

Use the Open method to open a presentation and add it to the Presentations collection. The following example opens the file Sales.ppt as a read-only presentation.

PowerPoint Object Model Reference

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.

Was this page helpful?

Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see: https://aka.ms/ContentUserFeedback .

Submit and view feedback for

Additional resources

How To View PowerPoint Add-in VBA Code Inside Visual Basic Editor

How To View PowerPoint Add-in VBA Code Inside Visual Basic Editor

Where Did My Code Go?

That was the question I was asking myself when I first began to create PowerPoint add-ins for my own personal use.  With much research, I came to the realization that PowerPoint doesn't like to show VBA code associated with presentation files that are of the add-in format. Luckily I was able to find a very simple workaround to this problem that will at least let you view your add-in code in real-time while in PowerPoint.

I found these steps through Shyam Pillai's PowerPoint MVP website and I want to thank him for sharing this and a bunch of other great PowerPoint tips on his site.

Modifying Your Registry

  • Close down PowerPoint
  • Go to your Start Menu and find your Run  application (the easiest way is to type 'Run' in your search box)
  • Type in Regedit.exe and click OK
  • Navigate to the following key in the registry tree*:  HKEY_CURRENT_USER\Software\Microsoft\Office\15.0\PowerPoint\Options
  • Find the key name DebugAddins .  If you do not see it you will need to create it (steps for this are shown in the next section)
  • Double click on DebugAddins and in the window that pops up ensure the DWORD value is 1 and click OK
  • Launch PowerPoint and go into your Visual Basic Editor (Alt+F11).  You will now be able to see any PowerPoint add-in VBA code that is currently running

*Note that the 15.0 may be a different number based on the Office version you are running (12.0 is Office 2007, 14.0 is Office 2010)

iew Microsoft PowerPoint Add-in VBA macro code - Modify Registry Steps

How To Create the DebugAddins Key

More than likely you are not going to have the DebugAddins key created in your Options folder, so you are going to have to create one. Make sure immediately after you create the new DWORD value that you rename it DebugAddins .  Once the name is set there is no way to modify it (if have the wrong name, just right-click on the name and delete the line item, then start over).  Below are the steps you will need to take to create your registry key.

iew Microsoft PowerPoint Add-in VBA macro code - Modify Registry Steps

And You’re Done Messing With The Registry!

Confirm that you have the proper name, type, and data values in your line item and you are done!  Now you can start up your PowerPoint application and you will be able to see your VBA add-in projects inside the PowerPoint Visual Basic Editor.  Note you will not be able to save changes made to the add-in code.  If you need to make changes you will either have to modify your original PowerPoint Macro-enabled file that you used to create the add-in or you can make a new PowerPoint project and save it as a new add-in file.

iew Microsoft PowerPoint Add-in VBA macro code - Modify Registry Steps

After 10+ years of creating macros and developing add-ins, I've compiled all the hacks I wish I had known years ago!

Hidden Hacks For VBA Macro Coding

Keep Learning

How to Easily Install/Uninstall Excel VBA Add-in Files

How to Easily Install/Uninstall Excel VBA Add-in Files

Installing Your Excel Add-in1. Ensure Your Excel Add-in File Is Unblocked2. Save Your Excel Add-in File To Your Computer3. Enable...

Which Excel Versions Have XLOOKUP Function? [Solved]

Which Excel Versions Have XLOOKUP Function? [Solved]

Versions Of Microsoft Excel For XLOOKUP Function The following versions of Microsoft Excel include the XLOOKUP function: Excel 2021 or...

How To Ensure Your Microsoft Office VBA Add-in File Is Installed & Loaded

How To Ensure Your Microsoft Office VBA Add-in File Is Installed & Loaded

What This VBA Code Does There may be times when you want to incorporate code from your add-ins into other...

Chris Newman

Chris Newman

Chris is a finance professional and Excel MVP recognized by Microsoft since 2016. With his expertise, he founded TheSpreadsheetGuru blog to help fellow Excel users, where he shares his vast creative solutions & expertise. In addition, he has developed over 7 widely-used Excel Add-ins that have been embraced by individuals and companies worldwide.

VBA PowerPoint Slide Generation

Automating PowerPoint Slide Generation with VBA: A Game Changer

Abstract: In this article, we'll explore how to use VBA to generate PowerPoint slides with custom text frames and text ranges. This technique is particularly useful for creating teaching materials, such as game sequences.

In today's fast-paced world, time is of the essence. This is especially true in the business world, where presentations are a crucial part of communication. PowerPoint is a popular tool for creating presentations, but manually creating slides can be time-consuming. This is where VBA (Visual Basic for Applications) comes in. With VBA, you can automate the process of slide generation in PowerPoint, saving you time and increasing your productivity.

What is VBA?

VBA is a programming language developed by Microsoft that is built into many of its applications, including PowerPoint. It allows you to automate repetitive tasks, create custom functions, and interact with other applications. With VBA, you can create powerful macros that can perform a wide range of tasks, from simple formatting to complex data manipulation.

Automating PowerPoint Slide Generation

Creating slides in PowerPoint can be a tedious and time-consuming process, especially when you have to create a large number of slides with similar content. With VBA, you can automate this process and generate slides in a matter of seconds. Here's how:

Step 1: Create a new PowerPoint presentation

Use the following VBA code to create a new PowerPoint presentation:

Step 2: Add slides

Use the following VBA code to add slides to the presentation:

Step 3: Add content to the slides

Use the following VBA code to add content to the slides:

Key Concepts

Here are some key concepts to keep in mind when automating PowerPoint slide generation with VBA:

Objects: In VBA, everything is an object. For example, PowerPoint itself is an object, as is a presentation, a slide, and a shape. You can manipulate these objects using their properties and methods.

Properties: An object's properties describe its characteristics. For example, a slide's Title property describes the text of the slide's title.

Methods: An object's methods describe the actions it can perform. For example, a slide's Add method can be used to add a new slide to the presentation.

Loops: Loops are used to repeat a block of code a certain number of times. For example, you can use a loop to add 10 slides to a presentation.

Here are some references that you may find helpful when automating PowerPoint slide generation with VBA:

PowerPoint.Application Object

PowerPoint.Presentation Object

PowerPoint.Slide Object

PowerPoint.Shape Object

These references provide detailed information about the objects, properties, and methods available in PowerPoint's VBA object model. They also include examples that you can use to get started with automating PowerPoint slide generation.

In conclusion, automating PowerPoint slide generation with VBA can be a game changer for anyone who frequently creates presentations. With VBA, you can save time, increase your productivity, and create professional-looking presentations with ease. So why not give it a try?

Discover the power of VBA to create dynamic PowerPoint presentations. Learn how to use TextFrame and TextRange objects to generate slides with ease. Perfect for teachers and trainers!

Resolving inconsistent results with binance api node connector.

In this article, we will discuss a common issue encountered when using the Binance API Node Connector and provide solutions to resolve inconsistent results.

Quickway: Timber/Twig Image CDN Pull instead of WordPress

Learn how to use Timber and Twig to pull images from a CDN instead of WordPress.

Automating Shooting in C++: Performing a Predetermined Task at Certain Intervals

Learn how to implement an automated shooting function in C++ for a game, where the character shoots at predetermined intervals without receiving input.

Using Ocelot API Gateway with PreAuthorization Middleware for Service Name: SMSSMSProvider

In this scenario, clients want to use one upstream service (e.g., http://api.qwe.com/v1/sms) to send SMS messages. However, they want to implement pre-authorization checks before allowing access to the upstream service. This article explains how to use Ocelot API Gateway with PreAuthorization Middleware for the service name SMSSMSProvider.

Finding the Coefficient of a Linear Equation: aX

This article explores how to find the coefficient 'a' in the linear equation 'aX' using Python.

Removing Special Characters from a Column in R: An Example with data.frame

In this article, we provide an example of how to remove special characters from a column in R using the data.frame package.

SQL Querying with DuckDB and arrow in R: Workflow

This article explores how to use SQL queries with DuckDB and arrow in R, focusing on the intended use of plyr verbs.

Tags: :  PowerpointVBA TextFrame TextRange

Latest news

  • Creating Specific Dynamic Routes in Next.js for Album Pages
  • Automating iOS Simulator Downloads in CI/CD Pipelines
  • Replacing Uniform Textures (OGL) with New _BumpMap_ Colors
  • Creating a BigQuery Datatable with Weekly Range Start from the First Day of Each Year (2023-2024)
  • Importing a CSV File into a PostgreSQL Database with Conditions
  • Does the spaCy Dependency Parser Give Grammatically Incorrect Parse Trees?
  • Formatting Sentence Textbox: One-Line Solution
  • Retaining Date Value Using SAS Data Step: Creating a New Variable with STSCHGDATE
  • React Native: Unresolved 'notRead' property in JSON. Problem with fetching data and converting to JSON
  • Implementing CSS2DO Object Settings: Visible Occluded Meshes
  • Conditional Rendering with Datepicker Formkit Repeater
  • Error: Caller Not Permission using VideoIntelligence_v1p3beta1 API
  • Using New Scene on Load: Activating UI, Messing Main Menu in Game Play Scene?
  • Changing Textfield Color with Google Material-Components-Web
  • Fine-tuning LLAMA7b with Lora and Deepseed: Out of Memory Error
  • Obtaining Source Code for STBUpgrader: Digital Satellite Receiver Processor Update Program
  • Animating Pagination: Implementing Framer Motion's StaggerChildren and AnimatePresence in Web Development
  • Assertion Execution Statement Unit Test in Kotlin
  • Automating Pipelines with Airflow: Handling Missing 'SubDagOperator' Default Args
  • Troubleshooting Discord Bot Output on Raspberry Pi Bootup
  • Pie Chart View Not Appearing on Screen Programmatically: A Solution
  • Counting Process Instances with Java Object Variables in Camunda REST API
  • Manipulating Timestamps in Pandas without using slice or integer label
  • Migrating from Checkout.liquid to Shopify's Checkout UI Extension: Replacing City Dropdown City Textfield
  • Equalling Length Quiver Vectors in Matlab: A Glance at the plotquiverfunction
  • Append Child: Drag and Drop Hierarchically Equal divs using Typescript
  • Converting a Web App to a Windows Desktop App: A Step-by-Step Guide
  • Making Links Appear Plain Text for Screen Readers in Software Development Sites
  • Error Parsing Kafka.NET Application: Invalid URI: Authority/Host
  • Exploring Front-End Development Challenges: Seeking Guidance on React-Solana Integration
  • Combining Rows Based on Values in Different Columns: A SQL Example
  • Properly Dealing with Working Directories in knitr and RLaTeX with Different Paths
  • Integrating Auth0 OAuth Login with Laravel 9 Breeze for Multiple Users
  • Defining Polymorphic Marshmallow Schema in Python: UserSchema Example
  • Error Installing MediaPipe for Windows 11 with Python 3.12

powerpoint presentation vba code

Create Beautiful PowerPoint Slides with ChatGPT and VBA

  • June 14, 2023

Here’s a quick tip to boost your productivity by letting ChatGPT and VBA do the heavy lifting when creating PowerPoint slide decks.

If you don’t know what VBA is, no worries. It stands for Visual Basic for Applications and is integrated into all Microsoft Office applications, including PowerPoint. And no, you don’t have to be a programmer to make this work for you. Your existing copy/paste skills will do just fine…

Let me show you.

Here are the specific steps to take to boost your productivity when creating PowerPoint slide decks:

Visit ChatGPT and prompt it to write an outline for a PowerPoint presentation. Let’s pretend we want a pitch deck with maximum seven slides to present SmartPet Buddy, a fictitious robotic companion for pets.

The ChatGPT prompt could look like this:

You are an entrepreneur who invented SmartPet Buddy: A robotic companion for pets that offers interactive play, exercise, and monitoring, keeping pets entertained and active even when their owners are away. Real fun for your the whole family...including your best friends.

Write the outline for a slide deck to pitch this amazing product to prospective customers. Tell them about how exciting their lives will be with SmartPet Buddy in the house. Focus on the benefits more so than the features.

Tell your audience what the product does for them and what it means to them in their life rather than what it is by listing feature after feature.

Use no more than 7 slides in this deck.

ChatGPT will then produce the outline for this slide deck, just like we asked it to do.

If you like what ChatGPT presents to you, cool. Otherwise either hit the “Regenerate Response” button — or suggest what kind of modifications you want.

Once you are satisfied with the outline for your slide deck, it’s time to bring VBA into play. We are going to prompt ChatGPT to generate the required VBA code for PowerPoint from the outline:

Now write the VBA code to create the PowerPoint slides for this pitch. Add content that is humorous and whimsical to reflect just how fun the product is.

As always, ChatGPT, our skilled and willing digital assistant, will oblige and create a block of code for us. We can then copy this code and hop over to PowerPoint.

Copy the VBA code ChatGPT generated so you can paste it into PowerPoint's Visual Basic Editor.

In PowerPoint, launch the Visual Basic Editor by pressing Alt-F11 or selecting Visual Basic Editor from the Tools/Macro menu.

To get your VBA code into PowerPoint, launch the Visual Basic Editor by pressing Alt-F11 (or select it from the Tools -> Macro menu).

Then, right click on the Project Panel and select Insert -> Module.

Insert a module by right-clicking on the Project panel in the Visual Basic Editor.

A new window will open. Paste the code you copied from ChatGPT into this window and then run the code by clicking on the ► icon.

Once you inserted the code (the real magic to make PowerPoint and VBA do the heavy lifting), run the code by clicking on the 'play' icon or choose it from the Run menu.

And that’s it!

This piece of code has now created a new PowerPoint presentation with 7 slides with minimal text on each.

Now all that’s left is to make it pretty by using PowerPoint’s Designer feature:

Here is where the real magic happens to make your slides pretty by using PowerPoint and VBA. Open the Designer to see a list of suggested designs based on your content.

The Designer is powered by AI as well and will read your slides and suggest a appropriate designs and images.

All you need to do is to select one of the designs you like. Then, fine-tune each slide to make sure your message will resonate with your audience — and voila… You have created a beautiful slide deck in no time.

In case you’re having trouble with the code, here is the snippet that worked for me:

Get instant access to my newsletter where I share my best presentation tips.

100% Privacy. No Spam.

More Presentation Tips

Preparation and coaching were key for Haley McClain Hill's Shark Tank success

10 Key Takeaways from a Shark Tank Success Story

Learn from Haley McClain Hill’s Shark Tank success story what it takes to prepare for Shark Tank — and secure a deal!

PowerPoint Cameo - Banner

Enter the Spotlight with PowerPoint Cameo

PowerPoint Cameo is a hidden gem, a powerful feature that allows you to seamlessly integrate your live video feed into your presentation slides.

ChatGPT Voice - Your Universal Translator

ChatGPT Voice – A Translator in Your Pocket

For anyone who has ever wished for a universal translator à la ‘Star Trek’ – our sci-fi dreams are coming closer to reality, thanks to ChatGPT Voice.

Latest PitchZone Episode

Related posts.

Where to Start When Creating an Investor Pitch

Where to Start when Creating an Investor Pitch

Creating an investor pitch can be quite a challenge. So it’s tempting to use a pitch deck template. But there is a better way…

RomperJack on Shark Tank

How I helped RomperJack prepare for Shark Tank

What does it take to prepare for Shark Tank? Find out in this interview with the remarkable founders of RomperJack.

Stay informed

Subscribe to my email list and receive news and tips that will help you become a more effective presenter.

I never share your contact info. And you can unsubscribe at any time.

Copyright 2024 © All rights Reserved.

Privacy policy.

VIDEO

  1. 4 Table Animation Hacks With ChatGPT + PowerPoint

  2. How To Create PowerPoint Presentation Using ChatGPT WITHOUT Running VBA Code

  3. การใช้ ChatGPT เขียนโค้ด VBA ไปสร้าง PowerPoint Presentation

  4. VBA Powerpoint : Dynamic Ribbon + Code Exporter + Edit Addins

  5. PowerPoint_VBA Component 불러오기

  6. Powerful Presentations in Minutes: ChatGPT + VBA Quick Tips!

COMMENTS

  1. How to use VBA in PowerPoint: A beginner's guide

    Getting to meet your VBA friend is very simple. With PowerPoint open and at least one presentation file open, press Alt+F11* on your keyboard. This will open the VBE (Visual Basic Editor): *If for some reason Alt+F11 isn't mapped on your keyboard you can right click anywhere on the ribbon, select Customize the Ribbon… and in the window that ...

  2. PowerPoint VBA Macro Examples & Tutorial

    PowerPoint Application. When VBA code is running within a PowerPoint Presentation, PowerPoint Application is the default application and it can be manipulated without explicitly reference. Create a New Presentation. To create a presentation, use the Add method of PowerPoint application.

  3. VBA Tutorial to Create Powerpoint Presentation

    Step 8: We need to add a presentation to the PowerPoint app we have launched. Code: Set PPPresentation = PPApp.Presentations.Add. Now, we should see the PowerPoint presentation like this. Step 9: We need to add a slide after adding the presentation. Code: Set PPSlide = PPPresentation.Slides.Add (1, ppLayoutTitleOnly)

  4. VBA PowerPoint

    See some interesting examples of how to create a PowerPoint presentation using Excel VBA. Example #1. Suppose you want to create a Title page for your PowerPoint presentation via code. You can do that by using VBA PowerPoint online. Step 1: Define the subroutine, which will create a PowerPoint Title page.

  5. How to Open and Use VBA Macro Editor in PowerPoint

    Steps to open the VBA macro editor. 1. Create a new presentation or open an existing one. Then go to the File tab and click on Options. 2. Click on Customize Ribbon, and check the box next to Developer and click OK. 3. Go to the Developer tab and click on Visual Basic. Another way is to press Alt + F11 on your keyboard.

  6. Run a macro in PowerPoint

    To run a macro in PowerPoint, the Developer tab must be visible on the ribbon. See Show the Developer tab. On the Developer tab, in the Code group, click Macros. In the Macro dialog box, under Macro name, select the macro that you want, and then click Run. For information about the security risks of macros and enabling or disabling macros in ...

  7. Create PowerPoint Presentations Automatically using VBA

    So, if worksheet "A"s print range is set to print on one page and worksheet "B"s print range is set to print on 3 pages, the PowerPoint presentation should have a total of 4 slides. I could end up with 10 worksheets in total representing 10+ slides needed in the presentation. Am new to VBA and would appreciate the help.

  8. VBA Macro to create Powerpoint presentation and add slides

    In the VB Editor, right click on VBAProject and hit Insert. Select Module. Paste the following code in the newly create module. Sub CreateSlide() Dim NewSlide as Slide. 'This statement ads a title slide. Set NewSlide = ActivePresentation.Slides.Add(Index:=1, Layout:=ppLayoutTitle) 'This statement adds a blank slide in the second place.

  9. PowerPoint Visual Basic for Applications (VBA) reference

    Use the table of contents in the navigation on the left to view the topics in the following sections: Concepts: Provides important concepts for developing custom PowerPoint solutions. How-to topics: Provides step-by-step instructions for developing custom PowerPoint solutions. Object model reference: Provides reference materials for the ...

  10. Supercharging PowerPoint interactive presentations with VBA (Part 1

    If lIdx = ActivePresentation.Slides.Count Then lIdx = 1. The last step is to actually tell PowerPoint to go to this slide: SlideShowWindows (1).View.GotoSlide lIdx, msoTrue. The magic part of this is the tiny msoTrue on the end of the line. The GotoSlide method (think of a method as an action verb) takes two arguments.

  11. Create PowerPoint Presentation From Excel Using VBA

    Follow the below steps: Step 1: Go to VBA Tool menu as shown below and select References… option as shown below. Step 2: Once we do that we will get a References VBA Project windows. From that list select MS PowerPoint 15.0 Object Library as shown below. This will activate all the commands related to MS PowerPoint in VBA.

  12. How To Add VBA Code In PowerPoint

    In this video, we look at how we can add VBA code to PowerPoint so that we can automate the slide creation process.0:00:15 - Adding the Developer tab to the ...

  13. How to use PowerPoint Macros VBA

    This video shows how you can use VBA macros in your powerpoint presentations.Related videos : Macros in Microsoft Wordhttps://youtu.be/19kaQDHSIIc*****...

  14. vba

    The code to open the Powerpoint to the specific slide is the following (targ is a string like "Slide:12"): Function ... If you need to activate the presentation, try: VBA.AppActivate (Dir(PptPath)) ... ppPres is PowerPoint.Presentation.

  15. VBA in PowerPoint

    What This VBA Code Does Often times we want to make changes that affect every slide in the PowerPoint presentation.... How To Mimic ThisPresentation In VBA For PowerPoint What This VBA Code Does It's unfortunate that the Microsoft developer's did not include a ThisPresentation class in PowerPoint's VBA...

  16. Presentations object (PowerPoint)

    Use the Presentations property to return the Presentations collection. Use the Add method to create a new presentation and add it to the collection. The following example creates a new presentation, adds a slide to the presentation, and then saves the presentation. Set newPres = Presentations.Add(True) newPres.Slides.Add 1, 1.

  17. How To View PowerPoint Add-in VBA Code Inside Visual Basic Editor

    If you do not see it you will need to create it (steps for this are shown in the next section) Double click on DebugAddins and in the window that pops up ensure the DWORD value is 1 and click OK. Launch PowerPoint and go into your Visual Basic Editor (Alt+F11). You will now be able to see any PowerPoint add-in VBA code that is currently running.

  18. Automating PowerPoint Slide Generation with VBA: A Game Changer

    Here are some references that you may find helpful when automating PowerPoint slide generation with VBA: PowerPoint.Application Object. PowerPoint.Presentation Object. PowerPoint.Slide Object. PowerPoint.Shape Object. These references provide detailed information about the objects, properties, and methods available in PowerPoint's VBA object model.

  19. Create Beautiful PowerPoint Slides with ChatGPT and VBA

    In PowerPoint, launch the Visual Basic Editor by pressing Alt-F11 or selecting Visual Basic Editor from the Tools/Macro menu. Then, right click on the Project Panel and select Insert -> Module. A new window will open. Paste the code you copied from ChatGPT into this window and then run the code by clicking on the icon.

  20. Getting the Active Slide of a PPT Presentation via VBA (but from Excel

    Specifying the first slide in the range will solve the first problem: ActiveWindow.Selection.SlideRange (1).SlideIndex and forcing the view to Normal and back will generally force the selection onto the slide just prior in the second case. - Steve Rindsberg. Jan 20, 2021 at 20:16. Add a comment.

  21. Creating a PowerPoint Presentation using ChatGPT

    Running VBA and Obtaining the PowerPoint File. VBA is a language that PowerPoint has built-in support. You can run the code and obtain a PowerPoint file in the following steps. Firstly, open your PowerPoint application and create a new presentation. Then, you should find "Visual Basic Editor" in the "Tools" menu, under "Macro" submenu.