Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 120
Default All charts in workbook to powerpoint

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
--------------------------------------------------------------------------------
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,391
Default All charts in workbook to powerpoint

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" wrote in message
...
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


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 120
Default All charts in workbook to powerpoint

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" wrote in message
...
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" wrote in message
...
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
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
Help! How to add many excel charts into PowerPoint at once? Joules Charts and Charting in Excel 1 July 13th 06 06:58 PM
Creating Charts for Use in Powerpoint tpearo Charts and Charting in Excel 0 June 21st 06 05:58 PM
Charts in each sheet to Powerpoint [email protected] Charts and Charting in Excel 6 June 24th 05 10:48 PM
Xcel charts into Powerpoint Travis Charts and Charting in Excel 0 February 11th 05 05:11 AM
vba for PowerPoint Charts KevDu Excel Programming 0 April 28th 04 05:43 PM


All times are GMT +1. The time now is 09:02 AM.

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"