Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 1
Default Can I paste a chart from Excel into a powerpoint slide "Placeholde

I have a macro to transfer Excel graphs into PowerPoint slides, which works
fine, but the pasted graphs (pictures) are (with original shape pasted across
teh slide. I would like them to get pasted into the "Placeholder" that is
automatically created on a new slide.
Anyone have an idea how to get this done?

Thanks in advance

Mats


Sub TransferGraphs()
'
' TransferGraphs Macro
' Transfer all graphs on selected worksheet as pictures to PPT file
'

Dim PPApp As PowerPoint.Application
Dim PPPres As PowerPoint.Presentation
Dim PPSlide As PowerPoint.Slide
Dim PresentationFileName As Variant
Dim SlideCount As Long
Dim iCht As Integer
Dim sTitle As String

' Create instance of PowerPoint
Set PPApp = CreateObject("Powerpoint.Application")

' For automation to work, PowerPoint must be visible
' (alternatively, other extraordinary measures must be taken)
PPApp.Visible = True

' Create a presentation
Set PPPres = PPApp.Presentations.Add

PPApp.ActiveWindow.ViewType = ppViewSlide

For iCht = 1 To ActiveSheet.ChartObjects.Count
With ActiveSheet.ChartObjects(iCht).Chart

' get chart title
If .HasTitle Then
sTitle = .ChartTitle.Text
Else
sTitle = ""
End If

' remove title (or it will be redundant)
.HasTitle = False

' copy chart as a picture
.CopyPicture _
Appearance:=xlScreen, Size:=xlScreen, Format:=xlPicture

' restore title
If Len(sTitle) 0 Then
.HasTitle = True
.ChartTitle.Text = sTitle
End If
End With

' Add a new slide and paste in the chart
SlideCount = PPPres.Slides.Count
Set PPSlide = PPPres.Slides.Add(SlideCount + 1, ppLayoutObject)
PPApp.ActiveWindow.View.GotoSlide PPSlide.SlideIndex
With PPSlide
' paste and select the chart picture
.Shapes.Paste.Select
' align the chart TO THE MIDDLE OF THE SLIDE AND INSERT THE SLIDE
TITLE (COPIED FROM THE GRAPH)
PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True
.Shapes.Placeholders(1).TextFrame.TextRange.Text = sTitle
End With

Next

' Save and close presentation
With PPPres
.SaveAs "C:\MACROTEST\MACROTEST.ppt"
.Close
End With

' Quit PowerPoint
' PPApp.Quit

' Clean up
Set PPSlide = Nothing
Set PPPres = Nothing
Set PPApp = Nothing

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.charting
external usenet poster
 
Posts: 6,582
Default Can I paste a chart from Excel into a powerpoint slide "Placeholde

I don't think you can paste it "in" the placeholder, but I'm sure you can
adjust your code to determine the size and position of the placeholder, and
resize and reposition the pasted chart accordingly.

- Jon
-------
Jon Peltier, Peltier Technical Services, Inc.
http://PeltierTech.com/WordPress/
Advanced Excel Conference - Training in Charting and Programming
http://peltiertech.com/Training/2009...00906ACNJ.html
_______


"Mats Teir" wrote in message
...
I have a macro to transfer Excel graphs into PowerPoint slides, which works
fine, but the pasted graphs (pictures) are (with original shape pasted
across
teh slide. I would like them to get pasted into the "Placeholder" that is
automatically created on a new slide.
Anyone have an idea how to get this done?

Thanks in advance

Mats


Sub TransferGraphs()
'
' TransferGraphs Macro
' Transfer all graphs on selected worksheet as pictures to PPT file
'

Dim PPApp As PowerPoint.Application
Dim PPPres As PowerPoint.Presentation
Dim PPSlide As PowerPoint.Slide
Dim PresentationFileName As Variant
Dim SlideCount As Long
Dim iCht As Integer
Dim sTitle As String

' Create instance of PowerPoint
Set PPApp = CreateObject("Powerpoint.Application")

' For automation to work, PowerPoint must be visible
' (alternatively, other extraordinary measures must be taken)
PPApp.Visible = True

' Create a presentation
Set PPPres = PPApp.Presentations.Add

PPApp.ActiveWindow.ViewType = ppViewSlide

For iCht = 1 To ActiveSheet.ChartObjects.Count
With ActiveSheet.ChartObjects(iCht).Chart

' get chart title
If .HasTitle Then
sTitle = .ChartTitle.Text
Else
sTitle = ""
End If

' remove title (or it will be redundant)
.HasTitle = False

' copy chart as a picture
.CopyPicture _
Appearance:=xlScreen, Size:=xlScreen, Format:=xlPicture

' restore title
If Len(sTitle) 0 Then
.HasTitle = True
.ChartTitle.Text = sTitle
End If
End With

' Add a new slide and paste in the chart
SlideCount = PPPres.Slides.Count
Set PPSlide = PPPres.Slides.Add(SlideCount + 1, ppLayoutObject)
PPApp.ActiveWindow.View.GotoSlide PPSlide.SlideIndex
With PPSlide
' paste and select the chart picture
.Shapes.Paste.Select
' align the chart TO THE MIDDLE OF THE SLIDE AND INSERT THE SLIDE
TITLE (COPIED FROM THE GRAPH)
PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True
.Shapes.Placeholders(1).TextFrame.TextRange.Text = sTitle
End With

Next

' Save and close presentation
With PPPres
.SaveAs "C:\MACROTEST\MACROTEST.ppt"
.Close
End With

' Quit PowerPoint
' PPApp.Quit

' Clean up
Set PPSlide = Nothing
Set PPPres = Nothing
Set PPApp = Nothing

End Sub



Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hyperlink from Excel to a specific slide in PowerPoint Bob W Excel Worksheet Functions 0 December 8th 08 04:46 PM
Link Powerpoint slide to Excel sheet dkc Excel Discussion (Misc queries) 1 July 26th 07 01:08 PM
I need to merge text from an Excel doc. into a powerpoint slide? trainer07 Excel Discussion (Misc queries) 1 June 29th 05 07:11 PM
A way to convert Excel worksheet into Powerpoint slide juzion Excel Discussion (Misc queries) 1 June 8th 05 01:38 AM
pasting excel data in a powerpoint slide James Excel Discussion (Misc queries) 4 January 28th 05 02:23 PM


All times are GMT +1. The time now is 05:49 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"