0
votes

I have written a code to copy charts dynamically from an excel workbook to a powerpoint presentation. What i am trying to do now is change the slide titles for each slide dynamically. here is a snippet of the code :

PPApp.ActivePresentation.Slides.Add PPApp.ActivePresentation.Slides.Count + 1, ppLayoutBlank
        PPApp.ActiveWindow.View.GotoSlide PPApp.ActivePresentation.Slides.Count
        Sheets("sheet1").Range("V1").Value = h
        Sheets("sheet1").Range("V11").Value = j
        Sheets("sheet1").Range("V22").Value = k
        Sheets("sheet1").Select
        ActiveSheet.ChartObjects("Chart 5").Activate
        ActiveSheet.ChartObjects("Chart 5").CopyPicture
        PPApp.ActiveWindow.View.Paste
        eachslideheader = Range("v2").Text & "my chart"
       PPApp.ActivePresentation.Slides.ppLayoutTitle.Add

PPApp.ActivePresentation.Slides.pplayouTitle.TextFrame.TextRange.Text = eachslideheader

This code gives an error while insert the title i am unable to figure it out.How should i proceed.Please help

1
What is the error? Which line is causing it?Ripster
the line where i add layout Title it throws an errorshiven

1 Answers

0
votes
' Assuming you're running this from w/in Excel ...
Dim oSl as Object    

' Get a reference to the added slide object to make things simpler later
' Make the new slide a TitleOnly layout so that it automatically gets a title
' placeholder:
Set oSl = PPApp.ActivePresentation.Slides.Add PPApp.ActivePresentation.Slides.Count + 1, _
      ppLayoutTitleOnly 
    ' ppLayoutTitleOnly = 11

            PPApp.ActiveWindow.View.GotoSlide PPApp.ActivePresentation.Slides.Count

            Sheets("sheet1").Range("V1").Value = h
            Sheets("sheet1").Range("V11").Value = j
            Sheets("sheet1").Range("V22").Value = k
            Sheets("sheet1").Select
            ActiveSheet.ChartObjects("Chart 5").Activate
            ActiveSheet.ChartObjects("Chart 5").CopyPicture
            PPApp.ActiveWindow.View.Paste
            eachslideheader = Range("v2").Text & "my chart"

'           PPApp.ActivePresentation.Slides.ppLayoutTitle.Add

'    PPApp.ActivePresentation.Slides.pplayouTitle.TextFrame.TextRange.Text = eachslideheader

oSl.Shapes.Title.Textframe.TextRange.Text = eachslideheader