Charts from EXCEL into PPT with .POT

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
 
S

Steve31530

Thanks for your help - This works really well!

As you can see I am using BitMap images from XLS but I really want
better quality results.

I could paste pictures but I really want to prevent any edits.
(Unscrupulous colleagues abound - Dilbert beware!)

Is there a way to stop conversion of imported pictures to MS office
drawing objects? I really need a solution that 'travels' with the
slide. Somehow I imagine creating the PPT from XLS using pictures and
then run a macro that would prevent further editing (convert all
pictures to ...). I have tried tests with paste-special-as-image but
I get the same quality problems I have today. The simple answer is to
PDF everything but there is a genuine need to mix-n-match slides in
PPT.

Alternatively a flag could be raised when the slide is edited...

Any ideas?

Thanks

Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top