VBA code to copy data into powerpoint 2010 chart from excel 2010?

josephjcota

New Member
Joined
Aug 19, 2011
Messages
1
VBA code to copy data into powerpoint 2010 chart from excel 2010?
I am trying to automate the process of populating the charts in the powerpoint (office 2010). Can anybody please help with the VBA code to

Copy data in excel > select the template chart in the powerpoint > open the data sheet > paste the copied data and close>loop

I am using office 2010, so please provide codes that work in office 2010.

I initially tried to create charts in excel and paste it in the powerpoint with the link and update the link whenever we get new data. However, after pasting couple of charts it becomes very slow. Since I have more than 200 charts, updating all the charts using VBA is my only option.
 
Sorry guys for starting up that conversation again but i'm a beginner and trying to sort of adapt the codes given above. But it doesn't work and i don't know why. Any inputs is more than welcome =)
here's the code:

----------------------------------------------------
Sub PWP()

Application.ScreenUpdating = False
Application.DisplayAlerts = False


Dim newPP As PowerPoint.Application
Set newPP = CreateObject("PowerPoint.Application")
Dim newPres As PowerPoint.Presentation
Set newPres = newPP.Presentations.Add
Set newPres = newPP.ActivePresentation
Dim slide As PowerPoint.slide
Dim chart As Excel.chart
Dim slide_counter As Long




newPP.Visible = True
newPP.ActiveWindow.ViewType = ppViewSlide


slide_counter = 0
For Each chart In ActiveWorkbook.Sheets("Dashboard").ChartObjects
Set slide = newPres.Slides.Add(slide_counter + 1, 12)
newPP.ActiveWindow.View.GotoSlide slide.SlideIndex

With chart
objchart.ChartArea.Copy
slide.Shapes.PasteSpecial(link = msoCTrue).Select

newPP.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
newPP.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True
End With

slide_counter = slide_counter + 1
Next


Set chart = Nothing
Set slide = Nothing
Set newPres = Nothing
Set newPP = Nothing


Application.ScreenUpdating = True
Application.DisplayAlerts = True


End Sub
 
Upvote 0

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Sorry guys for starting up that conversation again but i'm a beginner and trying to sort of adapt the codes given above. But it doesn't work and i don't know why. Any inputs is more than welcome =)
here's the code:

----------------------------------------------------
Sub PWP()

Application.ScreenUpdating = False
Application.DisplayAlerts = False


Dim newPP As PowerPoint.Application
Set newPP = CreateObject("PowerPoint.Application")
Dim newPres As PowerPoint.Presentation
Set newPres = newPP.Presentations.Add
Set newPres = newPP.ActivePresentation
Dim slide As PowerPoint.slide
Dim chart As Excel.chart
Dim slide_counter As Long




newPP.Visible = True
newPP.ActiveWindow.ViewType = ppViewSlide


slide_counter = 0
For Each chart In ActiveWorkbook.Sheets("Dashboard").ChartObjects
Set slide = newPres.Slides.Add(slide_counter + 1, 12)
newPP.ActiveWindow.View.GotoSlide slide.SlideIndex

With chart
objchart.ChartArea.Copy
slide.Shapes.PasteSpecial(link = msoCTrue).Select

newPP.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
newPP.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True
End With

slide_counter = slide_counter + 1
Next


Set chart = Nothing
Set slide = Nothing
Set newPres = Nothing
Set newPP = Nothing


Application.ScreenUpdating = True
Application.DisplayAlerts = True


End Sub

what error are you getting?
 
Upvote 0
OK try this....

Code:
Option Explicit
Sub PWP()

 Application.ScreenUpdating = False
 Application.DisplayAlerts = False


 Dim newPP As PowerPoint.Application
 Set newPP = CreateObject("PowerPoint.Application")
 Dim newPres As PowerPoint.Presentation
 Set newPres = newPP.Presentations.Add
 Set newPres = newPP.ActivePresentation
 Dim slide As PowerPoint.slide
 Dim chart As Object
 Dim slide_counter As Long




 newPP.Visible = True
 newPP.ActiveWindow.ViewType = ppViewSlide


 slide_counter = 0
  For Each chart In ActiveWorkbook.Sheets("Dashboard").ChartObjects
 Set slide = newPres.Slides.Add(slide_counter + 1, 12)
 newPP.ActiveWindow.View.GotoSlide slide.SlideIndex

 With chart
 chart.CopyPicture Appearance:=xlScreen, _
        Format:=xlPicture
 'chart.ChartArea.Copy
 slide.Shapes.Paste.Select

 newPP.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
 newPP.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True
 End With

 slide_counter = slide_counter + 1
 Next


 Set chart = Nothing
 Set slide = Nothing
 Set newPres = Nothing
 Set newPP = Nothing


 Application.ScreenUpdating = True
 Application.DisplayAlerts = True


 End Sub
 
Upvote 0
Thanks for your prompt replies guys but i found where the mistake is located =)). Thanks again
 
Upvote 0

Forum statistics

Threads
1,214,651
Messages
6,120,742
Members
448,989
Latest member
mariah3

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
Back
Top