title: Apply template to powerpoint in Excel VBA from embedded template file
body: <p>I'm trying to apply a template to a powerpoint through excel. The powerpoint template is embedded within my excel file via insert -> Object. I've successfully used the <code>.applytemplate</code> method to apply a template from file, but I cannot adjust the code to reference the embedded powerpoint template. I tried using OLEObject, but I'm afraid that isn't correct. Please review below code.</p>
  
  <pre><code>Sub ppCreate()
  
  Dim myPP As PowerPoint.Application
  Dim myPres As PowerPoint.Presentation
  Dim activeSlide As PowerPoint.Slide
  Dim ppObj As OLEObject
  
  ' Create instance of PowerPoint
  Set myPP = CreateObject("Powerpoint.Application")
  
  ' For automation to work, PowerPoint must be visible
  myPP.Visible = True
  
  
  ' Create a presentation
  Set myPres = myPP.Presentations.Add
  
  ' Set slide view to Slide Only
  myPP.ActiveWindow.ViewType = ppViewSlide
  
  'Resize to 4:3
  myPres.PageSetup.SlideSize = 2
  
  'Add a slide
  Set activeSlide = myPres.Slides.Add(1, ppLayoutBlank)
  
  'Import Template
  
  Worksheets("CBRDATA").Select
  Set ppObj = ActiveSheet.OLEObjects("ppObj")       'NOT WORKING
  myPres.ApplyTemplate (ppObj)                      'NOT WORKING
  myPres.ApplyTemplate "C:\CBR_TEMPLATE_COVER.potx" 'WORKING
  Worksheets("CBR").Select
  
  End Sub
  </code></pre>
  
  <p>Update:</p>
  
  <pre><code>'Test if template exists in C:\
  If Dir("C:\CBR_TEMPLATE_COVER.potx") = "" Then
      'Open/Save the embedded template to C:\
      Set tempPP = CreateObject("Powerpoint.Application")
      Worksheets("CBRDATA").OLEObjects("ppObj").Verb 0
      tempPP.Visible = True
      Set tempPres = tempPP.ActivePresentation
      tempPres.SaveCopyAs ("C:\CBR_TEMPLATE_COVER.potx")
      tempPres.Close
  Else:
  End If
  
  ' Create instance of PowerPoint
  Set myPP = CreateObject("Powerpoint.Application")
  </code></pre>