I'm not so good in VBA so I hope someone with more knowledge can help me. I have a *.xls file with nine Worksheet, in each worksheet there are two charts.
What I want to do is to move the two charts from worksheet one to first page of a powerpoint file, place the two charts next to each other. Make a animation so these two appear togeather.
Then place the two charts from worksheet two as next animation on top of the first one in the powerpoint file and so on for all nine worksheets.
The result will be one page powerpoint with nine animations points, showing 18 different charts.
I have so far below code (not mine) which move the charts, but create a new page for each chart, but I would want it to make a animation of each chart instead.
Hope someone can tell me how I can change the code or maybe a link to where it is explained.
Thank you
What I want to do is to move the two charts from worksheet one to first page of a powerpoint file, place the two charts next to each other. Make a animation so these two appear togeather.
Then place the two charts from worksheet two as next animation on top of the first one in the powerpoint file and so on for all nine worksheets.
The result will be one page powerpoint with nine animations points, showing 18 different charts.
I have so far below code (not mine) which move the charts, but create a new page for each chart, but I would want it to make a animation of each chart instead.
Hope someone can tell me how I can change the code or maybe a link to where it is explained.
Thank you
Code:
Option Explicit
Private Sub CommandButton1_Click()
exportCharts2Ppt
End Sub
Sub exportCharts2Ppt()
'Dim filename As String
' Create a PowerPoint application object.
Dim objPPT As PowerPoint.Application
Set objPPT = New PowerPoint.Application
objPPT.Visible = True ' Make the PPT visible.
objPPT.Activate
' Create a PowerPoint presentation object.
Dim objPptPre As PowerPoint.Presentation
Set objPptPre = objPPT.Presentations.Add
' We'll show different charts in different slides in our PowerPoint presentation.
' Therefore, create an object for PPT slides.
Dim objPPTSlides As PowerPoint.Slide
Dim iNdx As Integer ' Index, or position of each slide.
iNdx = 1
Dim objChart As ChartObject
Dim objWS As Worksheet
For Each objWS In ActiveWorkbook.Worksheets ' Loop through all the worksheets.
For Each objChart In objWS.ChartObjects ' Loop through all the Chart Objects.
objChart.Chart.ChartArea.Copy ' Copy all the charts to the Clipboard.
' Debug.Print objChart.Chart.Name
'ActiveChart.ChartTitle.Text = filename
Set objPPTSlides = objPptPre.Slides.Add(iNdx, ppLayoutBlank) ' Create a new slide with a blank layout.
objPPTSlides.Shapes.PasteSpecial ppPasteDefault, msoTrue ' Extract the chart from the Clipboad and paste it.
iNdx = iNdx + 1 ' Increment the slide index (or position).
Next objChart
Next objWS
End Sub