PC Review


Reply
Thread Tools Rate Thread

Charts Sheets to Powerpoint

 
 
kimbobo
Guest
Posts: n/a
 
      16th Apr 2007
I am using some code I got from a friend and it only appears to work
for embedded chart objects? I would like it to work for Charts that
are in the Chart Sheet format.

Any Suggestions?

Thanks!

Sub Charts_To_Presentation()

'''''''''''''''''''''''''''''''''''''''''''''''''''''
' This macro copies each chart in Excel and pastes it
' as a picture in PowerPoint
'''''''''''''''''''''''''''''''''''''''''''''''''''''

Dim oPowerPoint As New PowerPoint.Application
Dim appPPT As PowerPoint.Application
Dim pptPres As Presentation
Dim pptSlide As Slide
Dim appXL As Excel.Application
Dim ws As Worksheet
Dim ch As Chart
Dim aChtObj As ChartObject
Dim wkb As Workbook
Dim SlideCount As Long
Dim CurrentSheetName As String


''''''''''''''''''''''''''''''''''''''''''''''''''
' Creates a new Presentation and adds title slide
''''''''''''''''''''''''''''''''''''''''''''''''''

'Set pptPres = oPowerPoint.Presentations.Add

'With pptPres.Slides
' Set pptSlide = .Add(.Count + 1, ppLayoutTitleOnly)
' pptSlide.Shapes.Title.TextFrame.TextRange.Text = "XXX Survey"
'End With

''''''''''''''''''''''''''''''''''''''''''''
' Reference existing instance of PowerPoint
''''''''''''''''''''''''''''''''''''''''''''

Set appPPT = GetObject(, "Powerpoint.Application")
'Reference active presentation
Set pptPres = appPPT.ActivePresentation
appPPT.ActiveWindow.ViewType = ppViewSlide

'''''''''''''''''''''''''''''''''''''''
'Places each embedded chart in a slide
'''''''''''''''''''''''''''''''''''''''

For Each ws In ActiveWorkbook.Worksheets
CurrentSheetName = ws.Name
For Each aChtObj In ws.ChartObjects

''''''''''''''''''''''''
'copies chart
''''''''''''''''''''''''

aChtObj.Copy

''''''''''''''''''''''''''''''''''''''
'Adds a new slide and pastes the chart
''''''''''''''''''''''''''''''''''''''

SlideCount = pptPres.Slides.Count
Set pptSlide = pptPres.Slides.Add(SlideCount + 1, ppLayoutBlank)
appPPT.ActiveWindow.View.GotoSlide pptSlide.SlideIndex

pptSlide.Shapes.PasteSpecial(ppPasteMetafilePicture).Select
'centers the chart
appPPT.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters,
msoTrue
appPPT.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles,
msoTrue



''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Creates a text box and pastes the Excel sheet's name in it
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

appPPT.ActiveWindow.Selection.SlideRange.Shapes.AddTextbox(msoTextOrientationHorizontal,
5, 10, 625, 27).Select
appPPT.ActiveWindow.Selection.TextRange.ParagraphFormat.Alignment =
ppAlignLeft
appPPT.ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Characters(Start:=1,
Length:=0).Select
With appPPT.ActiveWindow.Selection.TextRange

.Text = CurrentSheetName
With .Font
.Name = "Arial"
.Size = 28
.Bold = msoFalse
End With
End With

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Creates a text box for the take-away
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

appPPT.ActiveWindow.Selection.SlideRange.Shapes.AddTextbox(msoTextOrientationHorizontal,
38, 67, 652, 27).Select
appPPT.ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Paragraphs(Start:=1,
Length:=1).ParagraphFormat.Bullet.Visible = msoFalse
appPPT.ActiveWindow.Selection.TextRange.ParagraphFormat.Alignment =
ppAlignLeft
appPPT.ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Characters(Start:=1,
Length:=0).Select
With appPPT.ActiveWindow.Selection.TextRange

.Text = "XXX"
With .Font
.Name = "Arial"
.Size = 20
.Bold = msoTrue
.Color.RGB = RGB(Red:=26, Green:=117, Blue:=206)
End With
End With

Next aChtObj
Next ws

End Sub

 
Reply With Quote
 
 
 
 
=?Utf-8?B?SkxHV2hpeg==?=
Guest
Posts: n/a
 
      17th Apr 2007
Maybe this site can give some help:

http://office.microsoft.com/en-us/po...045551033.aspx

"kimbobo" wrote:

> I am using some code I got from a friend and it only appears to work
> for embedded chart objects? I would like it to work for Charts that
> are in the Chart Sheet format.
>
> Any Suggestions?
>
> Thanks!
>
> Sub Charts_To_Presentation()
>
> '''''''''''''''''''''''''''''''''''''''''''''''''''''
> ' This macro copies each chart in Excel and pastes it
> ' as a picture in PowerPoint
> '''''''''''''''''''''''''''''''''''''''''''''''''''''
>
> Dim oPowerPoint As New PowerPoint.Application
> Dim appPPT As PowerPoint.Application
> Dim pptPres As Presentation
> Dim pptSlide As Slide
> Dim appXL As Excel.Application
> Dim ws As Worksheet
> Dim ch As Chart
> Dim aChtObj As ChartObject
> Dim wkb As Workbook
> Dim SlideCount As Long
> Dim CurrentSheetName As String
>
>
> ''''''''''''''''''''''''''''''''''''''''''''''''''
> ' Creates a new Presentation and adds title slide
> ''''''''''''''''''''''''''''''''''''''''''''''''''
>
> 'Set pptPres = oPowerPoint.Presentations.Add
>
> 'With pptPres.Slides
> ' Set pptSlide = .Add(.Count + 1, ppLayoutTitleOnly)
> ' pptSlide.Shapes.Title.TextFrame.TextRange.Text = "XXX Survey"
> 'End With
>
> ''''''''''''''''''''''''''''''''''''''''''''
> ' Reference existing instance of PowerPoint
> ''''''''''''''''''''''''''''''''''''''''''''
>
> Set appPPT = GetObject(, "Powerpoint.Application")
> 'Reference active presentation
> Set pptPres = appPPT.ActivePresentation
> appPPT.ActiveWindow.ViewType = ppViewSlide
>
> '''''''''''''''''''''''''''''''''''''''
> 'Places each embedded chart in a slide
> '''''''''''''''''''''''''''''''''''''''
>
> For Each ws In ActiveWorkbook.Worksheets
> CurrentSheetName = ws.Name
> For Each aChtObj In ws.ChartObjects
>
> ''''''''''''''''''''''''
> 'copies chart
> ''''''''''''''''''''''''
>
> aChtObj.Copy
>
> ''''''''''''''''''''''''''''''''''''''
> 'Adds a new slide and pastes the chart
> ''''''''''''''''''''''''''''''''''''''
>
> SlideCount = pptPres.Slides.Count
> Set pptSlide = pptPres.Slides.Add(SlideCount + 1, ppLayoutBlank)
> appPPT.ActiveWindow.View.GotoSlide pptSlide.SlideIndex
>
> pptSlide.Shapes.PasteSpecial(ppPasteMetafilePicture).Select
> 'centers the chart
> appPPT.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters,
> msoTrue
> appPPT.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles,
> msoTrue
>
>
>
> ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
> ' Creates a text box and pastes the Excel sheet's name in it
> ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
>
> appPPT.ActiveWindow.Selection.SlideRange.Shapes.AddTextbox(msoTextOrientationHorizontal,
> 5, 10, 625, 27).Select
> appPPT.ActiveWindow.Selection.TextRange.ParagraphFormat.Alignment =
> ppAlignLeft
> appPPT.ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Characters(Start:=1,
> Length:=0).Select
> With appPPT.ActiveWindow.Selection.TextRange
>
> .Text = CurrentSheetName
> With .Font
> .Name = "Arial"
> .Size = 28
> .Bold = msoFalse
> End With
> End With
>
> ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
> ' Creates a text box for the take-away
> ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
>
> appPPT.ActiveWindow.Selection.SlideRange.Shapes.AddTextbox(msoTextOrientationHorizontal,
> 38, 67, 652, 27).Select
> appPPT.ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Paragraphs(Start:=1,
> Length:=1).ParagraphFormat.Bullet.Visible = msoFalse
> appPPT.ActiveWindow.Selection.TextRange.ParagraphFormat.Alignment =
> ppAlignLeft
> appPPT.ActiveWindow.Selection.ShapeRange.TextFrame.TextRange.Characters(Start:=1,
> Length:=0).Select
> With appPPT.ActiveWindow.Selection.TextRange
>
> .Text = "XXX"
> With .Font
> .Name = "Arial"
> .Size = 20
> .Bold = msoTrue
> .Color.RGB = RGB(Red:=26, Green:=117, Blue:=206)
> End With
> End With
>
> Next aChtObj
> Next ws
>
> 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
Macro to run on all files in a folder but exclude sheets with PivotTable, Pivot Charts and Charts Nasir Microsoft Excel Programming 16 11th Mar 2011 04:13 PM
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
Charts from Spread sheets nick g Microsoft Excel Misc 3 27th Jul 2005 05:01 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:05 AM.