Please help! Can vba copy & paste excel chart to my.pptx slide?

pedie

Well-known Member
Joined
Apr 28, 2010
Messages
3,875
Hi, I think i'm asking for BIG help here...

I have 3 sheets of excel workbook and 4 slides of PPT.
Can vba copy and paste/ replace the current picture [slide] that is in PPT?

Slide 1 has 2 pictures from sheet1.
Slide 2 has 1 pictures from sheet2.
Slide 3 has 3 pictures from sheet3.

Can someone pls instruct vba to do this for me?:)
file located in same folder:
E:\Personal_Files\LiveLessons\WeeklySH.pptx

Thank you soo much for helping me.
 

Excel Facts

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)
Hi, found something related but the code loops through and then paste the all chart to one slide...how can i correct that?

Thanks again.

Code:
[FONT=Courier New]Dim objPPT As Object[/FONT]
[FONT=Courier New]   Dim objPrs As Object[/FONT]
[FONT=Courier New]   Dim shtTemp As Worksheet[/FONT]
[FONT=Courier New]   Dim chtTemp As ChartObject[/FONT]
[FONT=Courier New]   Dim intSlide As Integer[/FONT]
 
[FONT=Courier New]   Set objPPT = CreateObject("Powerpoint.application")[/FONT]
[FONT=Courier New]   objPPT.Visible = True[/FONT]
[FONT=Courier New]   objPPT.Presentations.Open "E:\Personal_Files\LiveLessons\WeeklySH.pptx"[/FONT]
[FONT=Courier New]   objPPT.ActiveWindow.ViewType = 1 'ppViewSlide[/FONT]
 
[FONT=Courier New]   For Each shtTemp In ThisWorkbook.Worksheets[/FONT]
[FONT=Courier New]       For Each chtTemp In shtTemp.ChartObjects[/FONT]
[FONT=Courier New]           intSlide = intSlide + 1[/FONT]
[FONT=Courier New]           chtTemp.CopyPicture[/FONT]
[FONT=Courier New]           If intSlide > objPPT.Presentations(1).Slides.Count Then[/FONT]
[FONT=Courier New]               objPPT.ActiveWindow.View.GotoSlide Index:=objPPT.Presentations(1).Slides.Add(Index:=intSlide, Layout:=1).SlideIndex[/FONT]
[FONT=Courier New]           End If[/FONT]
[FONT=Courier New]           objPPT.ActiveWindow.View.Paste[/FONT]
[FONT=Courier New]       Next[/FONT]
[FONT=Courier New]   Next[/FONT]
[FONT=Courier New]   objPPT.Presentations(1).Save[/FONT]
[FONT=Courier New]   objPPT.Quit[/FONT]
 
[FONT=Courier New]   Set objPrs = Nothing[/FONT]
[FONT=Courier New]   Set objPPT = Nothing[/FONT]
 
Upvote 0
Brian, thanks alo....t for the link...it has lots of examples...
Reading it through but i think it won't be that easy to fix this thing myself..:) but checking ....


If anyone can help then it still 'd be Great!:)
 
Upvote 0
Hi Pedie

This really isn't my thing, but try the below it works for me.

open Excel and create some charts, and with powerpoint open.
run the Sub ChartsAndTitlesToPresentation(), from Jon Peltier.
Don't forget to "Set a VBE reference to Microsoft PowerPoint Object Library"
 
Last edited:
Upvote 0
I really do appriciate your help Brian..
Thank you very much!
'll try it out that way...
've been trying different ways myself:)


Have a Great Weekends!!!
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,613
Messages
6,179,904
Members
452,948
Latest member
Dupuhini

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