Solved

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

Posted on 2012-03-18
3
323 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Lync 2013 5 31
Outlook 2013 Categories disabled 7 62
PDF file with inconsistent formatting that makes no sense 3 64
Inventory Pipeline Production Line Excel Simulation 17 121
I recently resolved a client's Office 2013 installation problem and wanted to offer an observation that may help you with troubleshooting similar issues. The client ordered three Dell Optiplex system units with the Windows 7 downgrade option inst…
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…
The viewer will learn how to simulate a series of sales calls dependent on a single skill level and learn how to simulate a series of sales calls dependent on two skill levels. Simulating Independent Sales Calls: Enter .75 into cell C2 – “skill leve…
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

860 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