VBA Error

vmoore845

New Member
Joined
Oct 5, 2020
Messages
14
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!
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.

Jon Peltier

MrExcel MVP
Joined
May 14, 2003
Messages
4,974
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
14
Office Version
  1. 2010
Platform
  1. Windows
Thank you, that was my problem, I had to select PowerPoint in the Reference tools.
 

Forum statistics

Threads
1,144,660
Messages
5,725,645
Members
422,634
Latest member
YenOlmedo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top