VBA Error

vmoore845

New Member
Joined
Oct 5, 2020
Messages
9
Office Version
  1. 2010
Platform
  1. Windows
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:

1601943734055.png


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!
 

Some videos you may like

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Jon Peltier

MrExcel MVP
Joined
May 14, 2003
Messages
4,922
Office Version
  1. 365
Platform
  1. Windows
  2. MacOS
Do you have a reference to the PowerPoint Object Library in this VB project?

What is highlighted when you get the error?
 

vmoore845

New Member
Joined
Oct 5, 2020
Messages
9
Office Version
  1. 2010
Platform
  1. Windows
Thank you, that was my problem, I had to select PowerPoint in the Reference tools.
 

Watch MrExcel Video

Forum statistics

Threads
1,114,070
Messages
5,545,816
Members
410,708
Latest member
SanTrapGamer
Top