PC Review


Reply
Thread Tools Rate Thread

All charts in workbook to powerpoint

 
 
Mark Ivey
Guest
Posts: n/a
 
      9th Nov 2006
Below is some code from Jon Peltier's website for transferring all charts from one worksheet to a presentation. I have tried several times to figure out how to get this to cycle through the workbook and get every chart in the workbook to do the same, but I cannot seem to figure it out. Can anyone help me with this? I have opted to paste in Jon Peltier's original code since I kept bugging up what was already there...
Thanks in advance...

--------------------------------------------------------------------------------

Sub ChartsToPresentation()
' Set a VBE reference to Microsoft PowerPoint Object Library

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

' Reference existing instance of PowerPoint
Set PPApp = GetObject(, "Powerpoint.Application")
' Reference active presentation
Set PPPres = PPApp.ActivePresentation
PPApp.ActiveWindow.ViewType = ppViewSlide

For iCht = 1 To ActiveSheet.ChartObjects.Count
' copy chart as a picture
ActiveSheet.ChartObjects(iCht).Chart.CopyPicture _
Appearance:=xlScreen, Size:=xlScreen, Format:=xlPicture

' Add a new slide and paste in the chart
SlideCount = PPPres.Slides.Count
Set PPSlide = PPPres.Slides.Add(SlideCount + 1, ppLayoutBlank)
PPApp.ActiveWindow.View.GotoSlide PPSlide.SlideIndex
With PPSlide
' paste and select the chart picture
.Shapes.Paste.Select
' align the chart
PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True
End With

Next

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

End Sub
--------------------------------------------------------------------------------
 
Reply With Quote
 
 
 
 
NickHK
Guest
Posts: n/a
 
      9th Nov 2006
Mark,
I would assume you need to add another loop to cycle through all the
worksheets. e.g.
Dim WS as worksheet

For each ws in thisworkbook.worksheet
'For iCht = 1 To ActiveSheet.ChartObjects.Count
For iCht = 1 To WS.ChartObjects.Count
'Code, adjusted to WS instead of ActiveSheet
Next
Next

NickHK

"Mark Ivey" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
Below is some code from Jon Peltier's website for transferring all charts
from one worksheet to a presentation. I have tried several times to figure
out how to get this to cycle through the workbook and get every chart in the
workbook to do the same, but I cannot seem to figure it out. Can anyone help
me with this? I have opted to paste in Jon Peltier's original code since I
kept bugging up what was already there...
Thanks in advance...



Sub ChartsToPresentation()
' Set a VBE reference to Microsoft PowerPoint Object Library

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

' Reference existing instance of PowerPoint
Set PPApp = GetObject(, "Powerpoint.Application")
' Reference active presentation
Set PPPres = PPApp.ActivePresentation
PPApp.ActiveWindow.ViewType = ppViewSlide

For iCht = 1 To ActiveSheet.ChartObjects.Count
' copy chart as a picture
ActiveSheet.ChartObjects(iCht).Chart.CopyPicture _
Appearance:=xlScreen, Size:=xlScreen, Format:=xlPicture

' Add a new slide and paste in the chart
SlideCount = PPPres.Slides.Count
Set PPSlide = PPPres.Slides.Add(SlideCount + 1, ppLayoutBlank)
PPApp.ActiveWindow.View.GotoSlide PPSlide.SlideIndex
With PPSlide
' paste and select the chart picture
.Shapes.Paste.Select
' align the chart
PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True
End With

Next

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

End Sub


 
Reply With Quote
 
Mark Ivey
Guest
Posts: n/a
 
      9th Nov 2006
Outstanding Nick,

I was close to what you were showing here, but I was unsure of what to do
with the other ActiveSheet references.

Thanks a million...

Mark Ivey

"NickHK" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Mark,
> I would assume you need to add another loop to cycle through all the
> worksheets. e.g.
> Dim WS as worksheet
>
> For each ws in thisworkbook.worksheet
> 'For iCht = 1 To ActiveSheet.ChartObjects.Count
> For iCht = 1 To WS.ChartObjects.Count
> 'Code, adjusted to WS instead of ActiveSheet
> Next
> Next
>
> NickHK
>
> "Mark Ivey" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> Below is some code from Jon Peltier's website for transferring all charts
> from one worksheet to a presentation. I have tried several times to figure
> out how to get this to cycle through the workbook and get every chart in
> the
> workbook to do the same, but I cannot seem to figure it out. Can anyone
> help
> me with this? I have opted to paste in Jon Peltier's original code since I
> kept bugging up what was already there...
> Thanks in advance...
>
>
>
> Sub ChartsToPresentation()
> ' Set a VBE reference to Microsoft PowerPoint Object Library
>
> 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
>
> ' Reference existing instance of PowerPoint
> Set PPApp = GetObject(, "Powerpoint.Application")
> ' Reference active presentation
> Set PPPres = PPApp.ActivePresentation
> PPApp.ActiveWindow.ViewType = ppViewSlide
>
> For iCht = 1 To ActiveSheet.ChartObjects.Count
> ' copy chart as a picture
> ActiveSheet.ChartObjects(iCht).Chart.CopyPicture _
> Appearance:=xlScreen, Size:=xlScreen, Format:=xlPicture
>
> ' Add a new slide and paste in the chart
> SlideCount = PPPres.Slides.Count
> Set PPSlide = PPPres.Slides.Add(SlideCount + 1, ppLayoutBlank)
> PPApp.ActiveWindow.View.GotoSlide PPSlide.SlideIndex
> With PPSlide
> ' paste and select the chart picture
> .Shapes.Paste.Select
> ' align the chart
> PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters, True
> PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles, True
> End With
>
> Next
>
> ' Clean up
> Set PPSlide = Nothing
> Set PPPres = Nothing
> Set PPApp = Nothing
>
> End Sub
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help! charts disappearing, new charts crashing powerpoint UKExcelgeek Microsoft Powerpoint 2 7th Dec 2009 03:15 PM
Copy/Paste Charts; Define Destination of Charts in PowerPoint ryguy7272 Microsoft Excel Programming 2 24th Jan 2008 08:04 PM
print data behind charts in powerpoint without opening charts =?Utf-8?B?bWVyc2thbXA=?= Microsoft Powerpoint 0 10th Apr 2007 04:20 PM
Save charts of a workbook into another new workbook Ming Microsoft Excel Discussion 2 3rd Aug 2005 10:27 PM
Copying charts from workbook to workbook =?Utf-8?B?R2VvZmYgQw==?= Microsoft Excel Charting 2 13th Mar 2005 05:04 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:50 AM.