LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default opening up Powerpoint slide from Excel

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.SlideInde x)

' 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
 
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
How do I copy and paste a powerpoint slide from excel using vba co LilacSpokane Excel Programming 4 February 28th 08 10:04 PM
How do I create a new slide in PowerPoint from Excel using VBA? LilacSpokane Excel Programming 0 February 21st 08 10:46 PM
Excel sheet to Powerpoint slide Herve Excel Programming 1 December 8th 05 04:04 PM
pasting excel data in a powerpoint slide James Excel Discussion (Misc queries) 4 January 28th 05 02:23 PM
Using excel vba to produce a powerpoint slide KDUT Excel Programming 1 May 13th 04 01:56 PM


All times are GMT +1. The time now is 06:43 PM.

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"