S
SV
I am working in Excel2000 and PPT2003 under XP and I am trying to
transfer images of XLS charts into PPT.
So far I have made this work when using a standard white.ppt slide.
Now I want to use a specific .pot
I have some problems to make this work.
PPT opens and I get a "click to add first slide" message which (I I
intervene manually) leads to a blank page and the debugger pointes to
a problem (******* marks the spot).
What is going wrong?
Steve
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
' Create instance of PowerPoint
Set PPApp = CreateObject("Powerpoint.Application")
PPApp.Visible = True
' Create a presentation
Set PPPres = PPApp.Presentations.Add
'Set PPT template *******
PPApp.Presentations.Open Filename:="C:\Documents and
Settings\name\Application_ Data\Microsoft\Templates
\template_name.pot", Untitled:=msoTrue
' Some PowerPoint actions work best in normal slide
view
PPApp.ActiveWindow.ViewType = ppViewSlide
' Some PowerPoint actions work best in normal slide
view
PPApp.ActiveWindow.ViewType = ppViewSlide
' Add first slide to presentation
Set PPSlide = PPPres.Slides.Add(1, ppLayoutTitleOnly)
For iCht = 1 To ActiveWorkbook.Charts.Count
' Copy chartsheet as a picture
ActiveWorkbook.Charts(iCht).CopyPicture _
Appearance:=xlScreen, Size:=xlScreen,
Format:=xlBitmap
' 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
' position the chart
With PPApp.ActiveWindow.Selection.ShapeRange
.Top = 94 ' points
.Left = 58 ' points
.Width = 8.2 * 72
.Height = 5.6 * 72
End With
End With
Next
' Clean up
Set PPSlide = Nothing
Set PPPres = Nothing
Set PPApp = Nothing
End Sub
transfer images of XLS charts into PPT.
So far I have made this work when using a standard white.ppt slide.
Now I want to use a specific .pot
I have some problems to make this work.
PPT opens and I get a "click to add first slide" message which (I I
intervene manually) leads to a blank page and the debugger pointes to
a problem (******* marks the spot).
What is going wrong?
Steve
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
' Create instance of PowerPoint
Set PPApp = CreateObject("Powerpoint.Application")
PPApp.Visible = True
' Create a presentation
Set PPPres = PPApp.Presentations.Add
'Set PPT template *******
PPApp.Presentations.Open Filename:="C:\Documents and
Settings\name\Application_ Data\Microsoft\Templates
\template_name.pot", Untitled:=msoTrue
' Some PowerPoint actions work best in normal slide
view
PPApp.ActiveWindow.ViewType = ppViewSlide
' Some PowerPoint actions work best in normal slide
view
PPApp.ActiveWindow.ViewType = ppViewSlide
' Add first slide to presentation
Set PPSlide = PPPres.Slides.Add(1, ppLayoutTitleOnly)
For iCht = 1 To ActiveWorkbook.Charts.Count
' Copy chartsheet as a picture
ActiveWorkbook.Charts(iCht).CopyPicture _
Appearance:=xlScreen, Size:=xlScreen,
Format:=xlBitmap
' 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
' position the chart
With PPApp.ActiveWindow.Selection.ShapeRange
.Top = 94 ' points
.Left = 58 ' points
.Width = 8.2 * 72
.Height = 5.6 * 72
End With
End With
Next
' Clean up
Set PPSlide = Nothing
Set PPPres = Nothing
Set PPApp = Nothing
End Sub