Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,058
Default opening up Powerpoint slide from Excel

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.
--
Gary''s Student - gsnu201001


"c1802362" wrote:

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
.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default opening up Powerpoint slide from Excel

On Feb 20, 7:50*am, Gary''s Student
wrote:
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.
--
Gary''s Student - gsnu201001



"c1802362" wrote:
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
.


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
Reply
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 05:17 AM.

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"