Microsoft Office Tutorials and References
In Depth Information
Combined Procedures
Combined Procedures
The following procedures involve code that directs tasks to more than one
Transferring Charts From Excel to PowerPoint
by Suat Ozgur
This code demonstrates how to transfer Excel Charts in worksheets and to
create a new PowerPoint presentation file that includes a slide for each chart.
Example file:
Scenario: Presenting the charts in an Excel workbook using
a PowerPoint presentation is a time consuming task when
done by the traditional manual cut and paste. Now, you can
create that presentation easily using VBA.
View the Appendix to learn how to store this procedure
in a Standard module (in Excel).
Option Explicit¶
' * * * * *¶
Public Sub TransferToPPT()¶
'Excel Application objects declaration¶
Dim objSheet As Worksheet¶
Dim objChartObject As ChartObject¶
Dim objChart As Chart¶
'Powerpoint Application objects declaration¶
Dim pptApp As Object 'PowerPoint.Application¶
Dim pptPre As Object 'PowerPoint.Presentation¶
Dim pptSld As Object 'PowerPoint.Slide¶
'Create a new Powerpoint session¶
Set pptApp = CreateObject("PowerPoint.Application")¶
'Create a new presentation¶
Set pptPre = pptApp.Presentations.Add¶
'Loop through each worksheet¶
For Each objSheet In ActiveWorkbook.Worksheets¶
'Verify if there is a chart object to transfer¶
If objSheet.ChartObjects.Count > 0 Then¶
'Loop through each chart object in worksheet¶
For Each objChartObject In objSheet.ChartObjects¶
'Set chart object¶
Set objChart = objChartObject.Chart¶
Search JabSto ::

Custom Search