Solved

How do i open up a new PP presentation from template file from Windows using VBA

Posted on 2012-03-18
3
307 Views
Last Modified: 2012-03-25
Hi!

I have managed to open a PPT file using  the Shell and the run command.

" objShell = CreateObject("Wscript.Shell") "

But the problem is that it opens up the template itself, and it doesn't understand that it is supposed to generate a new document from the template when it opens up PowerPoint?
0
Comment
Question by:Musiqal
  • 2
3 Comments
 
LVL 59

Accepted Solution

by:
Chris Bottomley earned 500 total points
ID: 37736498
Try the following ... but modify the template string as appropriate.  I have shown two methods for adding a slide ... one direct and one to a variable ... the choice of which to use is yours.  The fist slide not surprisingly has to be '1' but after that change the first parameter to the add command to represent the slide to be added i.we. 1 adds as the first slide, 3 adds as the third slide BUT must never exceed the current number of slides by more than 1:

Sub presNew()
Dim pptApp As Object
Dim pres As Object
Dim strTemplate As String
Dim sld As Object
Const ppLayoutFourObjects As Integer = 24
Const ppLayoutTitle As Integer = 1

    strTemplate = "C:\Program Files\Microsoft Office\Templates\Presentation Designs\cliff.pot"
    Set pptApp = CreateObject("powerpoint.application")
    With pptApp.Presentations.Open(strTemplate, False, True, True)
                'Add slides as required ... i.e.
        .slides.Add 1, ppLayoutFourObjects
        Set sld = .slides.Add(1, ppLayoutTitle)
        sld.Shapes(1).TextFrame.textrange.Text = "I'm NEW!"
    End With

End Sub

Open in new window

0
 

Author Comment

by:Musiqal
ID: 37751403
This would have been great, but the problem is the slides need to be there from the beginning, any ideas?
0
 
LVL 59

Expert Comment

by:Chris Bottomley
ID: 37751771
If the slides exist in the template then they ought to be there ... the extra code supplied was to show how to add additional slides to the file derived from the template.

Chris
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Photo Albums in PowerPoint Photo Albums are a very useful tool in PowerPoint and allow you quickly add a large number of images. The images can be formatted in a variety of ways so that you are able to create a professional looking presentation v…
Meetings to discuss business process can waste time, and often do .  The meeting's dialog can get confusing when participants have different professional perspectives and backgrounds.  A jointly-developed process picture helps wade through the confu…
This video walks the viewer through the process of creating envelopes and labels, with multiple names and addresses. Navigate to the “Start Mail Merge” button in the Mailings tab: Follow the step-by-step process until asked to find the address doc…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now