opening up Powerpoint slide from Excel

C

c1802362

Hello

I'm running Excel 2003/Windows XP and am trying to get the following
to work:

I have a custom chart which is created from user input, after which
the user has the option of creating a powerpoint slide with a picture
of the chart on it.

Using John Peltier's late-binding code to create the chart picture and
push it to powerpoint, everything works fine - but only if a blank
powerpoint slide is already open. (I'm using late binding as I can't
expect my users to create a tool reference).

I'd like to allow the user to the option of opening a blank powerpoint
slide or an existing pre-formatted slide, without having the
Powerpoint app already open.

If I open Powerpoint ahead of launching the macro, everything works
fine. If Powerpoint is not open, I get runtime error 428 "ActiveX
component can't create object"

I tried substituting "Application.ActivateMicrosoftApp
xlMicrosoftPowerPoint" for the GetObject line (see ********* below),
but get an Error 91, "Object Variable Not set" at the next line
(annotated +++++++++ below). However, Powerpoint is launched and ready
to go.

Any suggestions?

Art

John Peltier's code:

Sub ChartToPresentation()
' Uses Late Binding to the PowerPoint Object Model
' No reference required to PowerPoint Object Library

Dim PPApp As Object ' As PowerPoint.Application
Dim PPPres As Object ' As PowerPoint.Presentation
Dim PPSlide As Object ' As PowerPoint.Slide

' Make sure a chart is selected
If ActiveChart Is Nothing Then
MsgBox "Please select a chart and try again.", vbExclamation, _
"No Chart Selected"
Else
' Reference existing instance of PowerPoint
Set PPApp = GetObject(, "Powerpoint.Application")
*********************
' Reference active presentation
Set PPPres = PPApp.ActivePresentation ++++++++++++++++++
PPApp.ActiveWindow.ViewType = 1 ' 1 = ppViewSlide
' Reference active slide
Set PPSlide = PPPres.Slides _
(PPApp.ActiveWindow.Selection.SlideRange.SlideIndex)

' Copy chart as a picture
ActiveChart.CopyPicture Appearance:=xlScreen, Size:=xlScreen, _
Format:=xlPicture

' Paste chart
PPSlide.Shapes.Paste.Select

' Align pasted chart
PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignCenters,
True
PPApp.ActiveWindow.Selection.ShapeRange.Align msoAlignMiddles,
True

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

End Sub
 
G

Gary''s Student

Consider using a hyperlink to a blank .ppt file instead. If PowerPoint is
already running, you will jump to the blank. If PowerPoint has not yet
started, activating the hyperlink will start it.
 
C

c1802362

Consider using a hyperlink to a blank .ppt file instead.  If PowerPointis
already running, you will jump to the blank.  If PowerPoint has not yet
started, activating the hyperlink will start it.

The Powerpoint app launches as advertised, but once the app is
running, all control from the VBA code is lost. So, what am I missing?
How do I get the chart picture that's been copied to the clipboard put
into the powerpoint slide then control returned to the VBA module in
Excel?

And, as long as we're at it, once in powerpoint, is there a way to
format the slide from the same VBA module in Excel?

Art
 

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