I use Sage Intelligence for all reports - I have created charts in 33 worksheets of a workbook and want to export to PowerPoint - I created the VBA (I copied it from someone else) I used it and worked great. I had to update the Excel file so after updating ran the Sage Intelligence reports (generates the Excel file); try to run the Script and am getting the following error:
Below is the Script:
Sub ExportChartsToPowerPoint_SingleWorkbook()
'Declare PowerPoint Variables
Dim PPTApp As Powerpoint.Application
Dim PPTPres As Powerpoint.Presentation
Dim PPTSlide As Powerpoint.Slide
Dim SldIndex As Integer
'Declare Excel Object Variables
Dim Chrt As ChartObject
Dim WrkSht As Worksheet
'Create a new instance of PowerPoint
Set PPTApp = New Powerpoint.Application
PPTApp.Visible = True
'Create a new Presentation within the Application
Set PPTPres = PPTApp.Presentations.Add
'Create an index handler for slide creation
SldIndex = 1
'Loop through all of the worksheets in the ACTIVEWORKBOOK
For Each WrkSht In Worksheets
'Loop through all the Chart Objects on the ACTIVESHEET
For Each Chrt In WrkSht.ChartObjects
'Copy the chart
Chrt.Copy
'Create a new slide, set the layout to blank, and paste chart on the slide
Set PPTSlide = PPTPres.Slides.Add(SldIndex, ppLayoutBlank)
PPTSlide.Shapes.Paste
'Increment our slide index
SldIndex = SldIndex + 1
Next Chrt
Next WrkSht
End Sub
Can someone help me figure out what is wrong?
Thank you!
Below is the Script:
Sub ExportChartsToPowerPoint_SingleWorkbook()
'Declare PowerPoint Variables
Dim PPTApp As Powerpoint.Application
Dim PPTPres As Powerpoint.Presentation
Dim PPTSlide As Powerpoint.Slide
Dim SldIndex As Integer
'Declare Excel Object Variables
Dim Chrt As ChartObject
Dim WrkSht As Worksheet
'Create a new instance of PowerPoint
Set PPTApp = New Powerpoint.Application
PPTApp.Visible = True
'Create a new Presentation within the Application
Set PPTPres = PPTApp.Presentations.Add
'Create an index handler for slide creation
SldIndex = 1
'Loop through all of the worksheets in the ACTIVEWORKBOOK
For Each WrkSht In Worksheets
'Loop through all the Chart Objects on the ACTIVESHEET
For Each Chrt In WrkSht.ChartObjects
'Copy the chart
Chrt.Copy
'Create a new slide, set the layout to blank, and paste chart on the slide
Set PPTSlide = PPTPres.Slides.Add(SldIndex, ppLayoutBlank)
PPTSlide.Shapes.Paste
'Increment our slide index
SldIndex = SldIndex + 1
Next Chrt
Next WrkSht
End Sub
Can someone help me figure out what is wrong?
Thank you!