Consulting

Results 1 to 5 of 5

Thread: Load and Manipulate Template

  1. #1
    VBAX Newbie
    Joined
    Nov 2017
    Posts
    3
    Location

    Load and Manipulate Template

    Hello! I'm generating some automatic PowerPoint presentations by copying and pasting data from several Excel workbooks. I have managed to do that successfully, but now I'm trying to load a template and then paste the Excel data on the template. After the data has been pasted, I will automatically save it as a non-template PowerPoint file.

    Below is the code that I am successfully using to generate a PowerPoint presentation and then paste the data I've copied from Excel. Thanks.

    script_powerpoint.jpg


    I didn't manage to past it here with the highlighting included (although I did copy it including the highlighting from Notepad++), so I'm attaching a word file also in case anybody is interested in copying the script.
    Attached Files Attached Files
    Last edited by iago; 11-26-2017 at 10:17 PM. Reason: code was not clear

  2. #2
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    This is how to start a new presentation based on a potx template

    Presentations.Open "<Path to potx>", Untitled:=True
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  3. #3
    VBAX Newbie
    Joined
    Nov 2017
    Posts
    3
    Location
    I forgot to mention a very important detail. I'm trying to open a file in the same folder where the macro is saved. When I'm opening a workbook, I use this code and it works fine:

    Workbooks.Open (ThisWorkbook.Path & ".\workbook1.xlsx")

    The macro in this case is still stored in a macro-enabled workbook file, so I thought of also using the ThisWorkbook.Path command. I tried the code below and it doesn't work.

    Presentations.Open (ThisWorkbook.Path & ".\template1.potx"), Untitled:=True
    Furthermore, I also need to associate the newly opened template document with a VBA variable so that I can manipulate it the same way I was doing with a presentation created from scratch.

    Many thanks.
    Last edited by iago; 11-27-2017 at 03:34 AM. Reason: code that was tried was not accurately stated

  4. #4
    VBAX Master
    Joined
    Feb 2007
    Posts
    2,093
    Location
    This works for me from excel

    Sub openTemplate()
    Dim ppt As Object
    Dim ppttemp As Object
    Set ppt = CreateObject(Class:="PowerPoint.Application")
    Set ppttemp = ppt.presentations.Open(ThisWorkbook.Path & "\notBlank.potx", untitled:=True)
    End Sub
    John Wilson
    Microsoft PowerPoint MVP
    Amazing Free PowerPoint Tutorials
    http://www.pptalchemy.co.uk/powerpoi...tutorials.html

  5. #5
    VBAX Newbie
    Joined
    Nov 2017
    Posts
    3
    Location
    Thank you John.

    Now if you were to save this same presentation as a .pptx file on the same folder of the macro, how would you do it?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •