Excel Charts to Powerpoint Paste Special

miseryofreflection

Board Regular
Joined
Jun 13, 2009
Messages
105
I used the following http://chandoo.org/wp/2011/08/03/cre...ing-excel-vba/

but then the issue I have is some axis on my interactive dashboard are cells and not part of the chart. So for me the best option would be to paste special into a powerpoint.


Sub CreateGraphicOnSlide()

Dim ppApp As PowerPoint.Application
Dim ppPres As PowerPoint.Presentation
Dim ppShape As PowerPoint.Shape
Dim ppCurrentSlide As PowerPoint.Slide
Dim r As Range, sh As Worksheet

'choose which range you want to use
Set r = ActiveSheet.Range("A1:O18")
'Set r = ActiveSheet.Range("A1:N30")

Worksheets.Add After:=Worksheets(Worksheets.Count)
Set sh = Worksheets(Worksheets.Count)
r.Parent.Activate
r.Select
Selection.CopyPicture Appearance:=xlScreen, Format:=xlPicture
sh.Pictures.Paste
sh.Shapes(1).Copy

Set ppApp = CreateObject("PowerPoint.Application")
ppApp.Visible = True

Set ppPres = ppApp.Presentations.Add(msoTrue)
Set ppCurrentSlide = ppPres.Slides.Add(Index:=1, Layout:=ppLayoutBlank)


With ppCurrentSlide
ppCurrentSlide.Shapes.Paste
Set ppShp = ppCurrentSlide.Shapes(1)
ppShp.Top = 50
ppShp.Left = 40

' use the following if necessary

' ppShp.width = ??
' ppShp.height = ??


End With

' Save the presentation and quit Microsoft PowerPoint.
'ppPres.SaveAs "c:\My Documents\pptExample2", ppSaveAsPresentation
'ppApp.Quit
Set ppApp = Nothing
Application.DisplayAlerts = False
sh.Delete
Application.DisplayAlerts = True
End Sub

Currently I am using that code. However, I would like it so each time the macor is run.. to input a new slide with the selection.

So the first time it is run.. create powerpoint, then for every following new slide.

R is defined as Set r = ActiveSheet.Range("A1:O18")
but I would like other variables like

Set s = ActiveSheet.Range("B20:R33")
Set t= ActiveSheet.Range("B34:R46")
 

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