Read our blogs, tips and tutorials
Try our exercises or test your skills
Watch our tutorial videos or shorts
Take a self-paced course
Read our recent newsletters
License our courseware
Book expert consultancy
Buy our publications
Get help in using our site
546 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owl trainers only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
Search our website
We also send out useful tips in a monthly email newsletter ...
Posted by Andrew Gould on 26 March 2014
Writing VBA code in Excel doesn't only allow you to control Excel, you also have access to all of the other Office applications. This video looks at how to create presentations in Microsoft PowerPoint by writing code in Excel. You'll learn how to reference the PowerPoint Object Library, several methods for creating a new instance of the PowerPoint application, how to create new presentations and insert slides and how to copy data from Excel into PowerPoint. You'll also learn the importance of testing for which version of PowerPoint your users are running and how to write version-independent code that will work with (almost) any version of PowerPoint.
See our full range of VBA training resources, or test your knowledge of VBA with one of our VBA skills assessment tests.
There are no files which go with this video.
There are no exercises for this video.
You can increase the size of your video to make it fill the screen like this:
Play your video (the icons shown won't appear until you do), then click on the full screen icon which appears as shown above.
When you've finished viewing a video in full screen mode, just press the Esc key to return to normal view.
To improve the quality of a video, first click on the Settings icon:
Make sure yoiu're playing your video so that the icons shown above appear, then click on this gear icon.
Choose to change the video quality:
Click as above to change your video quality.
The higher the number you choose, the better will be your video quality (but the slower the connection speed):
Don't choose the HD option shown unless your connection speed is fast enough to support it!
Is your Wise Owl speaking too slowly (or too quickly)? You can also use the Settings menu above to change your playback speed.
From: | duggie |
When: | 21 Mar 19 at 15:56 |
Hi,
I followed your video but encountered an error on this line:
PPSlide.Shapes.Paste
I think the reason is I am using Excel 2010, whereas you are using Excel 2013.
Can you tell me how can I adapt it to work for Excel 2010?
Thanks
From: | Andrew G |
When: | 25 Mar 19 at 11:53 |
Hi duggie,
This code works for PowerPoint 2010 with the code written in Excel 2010 using a reference to the Microsoft PowerPoint 14.0 Object Library:
Sub TestPresentation()
Dim ppt As PowerPoint.Application
Dim pres As PowerPoint.Presentation
Dim sld As PowerPoint.Slide
Shell "C:\Program Files (x86)\Microsoft Office\Office14\POWERPNT.EXE", vbNormalFocus
Set ppt = GetObject(Class:="PowerPoint.Application")
Set pres = ppt.Presentations(1)
Set sld = pres.Slides(1)
sld.Shapes(1).TextFrame2.TextRange.Text = "Test Presentation"
sld.Shapes(2).TextFrame2.TextRange.Text = "Wise Owl"
Set sld = pres.Slides.Add(2, ppLayoutBlank)
Worksheets("Sheet1").Range("A1:D6").Copy
sld.Shapes.PasteSpecial ppPasteOLEObject
Set sld = pres.Slides.Add(3, ppLayoutBlank)
Charts("Chart1").ChartArea.Copy
sld.Shapes.Paste
End Sub
I hope that helps!
From: | duggie |
When: | 29 Mar 19 at 10:46 |
Andrew,
Thanks for the update. Unfortunately I encountered the following problems when running your amended code:
When I copied and pasted your code into a new VBA workbook, I ran it and got this error:
Run-time error '-2147188160 (80048240)':
Presentations (unknown member): Integer out of range. 1 is not in the valid range 1 to 0.
Powerpoint is opened with a blank slide
I pressed the Debug option and this line is highlighted:
Set pres = ppt.Presentations(1)
I changed the 1 to a 0 (I wasn't sure what to do!) and pressed F5. I immediately got this error message:
Run-time error '-2147188160 (80048240)':
Presentations (unknown member): Integer out of range. 0 is not in the valid range 1 to 1.
I pressed Debug and the same line was at fault,
Set pres = ppt.Presentations(0)
so I changed it back from 0 to 1 and pressed F5.
Then I got a different error:
Run-time error '9'
Subscript out of range
though Powerpoint now contains a slide with Test Presentation and Wise Owl
Pressing debug shows this line at fault:
Charts("Chart1").ChartArea.Copy
Can you tell me if the problem lies with my Excel / Powerpoint combination or could it be something else?
Thanks
From: | Andrew G |
When: | 29 Mar 19 at 11:15 |
Hi duggie,
You can change this line:
Set pres = ppt.Presentations(1)
To this:
Set pres = ppt.Presentations.Add
The following line assumes that you have a chart called Chart1:
Charts("Chart1").ChartArea.Copy
You can change "Chart1" to the name of the chart you want to copy.
I hope that helps!
Incidentally, i had to use the following line in order to make PowerPoint 2010 run on my machine as I have later versions of Office installed:
Shell "C:\Program Files (x86)\Microsoft Office\Office14\POWERPNT.EXE", vbNormalFocus
If you only have Office 2010 installed you can remove the above line and then alter the line which uses the GetObject function to the version shown below:
Set ppt = CreateObject(Class:="PowerPoint.Application")
Kingsmoor House
Railway Street
GLOSSOP
SK13 2AA
Landmark Offices
99 Bishopsgate
LONDON
EC2M 3XD
Holiday Inn
25 Aytoun Street
MANCHESTER
M1 3AE
© Wise Owl Business Solutions Ltd 2024. All Rights Reserved.