Solved

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

Posted on 2012-03-18
3
327 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Companies keep a much closer eye on costs today, so changing to new Technology – Microsoft Office 365 is the smartest move to take.
When asking a question in a forum or creating documentation, screenshots are vital tools that can convey a lot more information and save you and your reader a lot of time
This video shows the viewer how to set up and create Footnotes in their document. Click on the References tab: Select "Insert Footnote": Type in desired text:
An overview on how to enroll an hourly employee into the employee database and how to give them access into the clock in terminal.

690 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