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: 96
Default Moving Excel Chart to Powerpoint (getting runtime error 91)

I have the following code created (highly leveraged from good examples here,
i might add) in which I wish to move a series of charts (and eventually data
tables) from an Excel file, to a ppt file . I get a "Run-time error '91':
Object variable or With block variable not set" when I execute this code (at
the WITH) statement.

I am an extreme noob at this, so would appreciate any pointers as to where I
have failed go clone this code properly. Note: I want to be able to update
the PPT file, and then save it under a name I have chosen.Thanks!

Pat


Sub ExcelToPowerpoint()

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


Set PPApp = CreateObject("Powerpoint.Application")
Set PPPres = PPApp.Presentations.Add
Set PPSlide = PPPres.Slides.Add(1, ppLayoutTitleOnly)

PPApp.Visible = True

' 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 = ppViewSlide
' Reference active slide
Set PPSlide =
PPPres.Slides(PPApp.ActiveWindow.Selection.SlideRa nge.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


With PPPres ' THIS IS WHERE I AM GETTING THE RUNTIME ERROR 91
.SaveAs "C:\Documents and Settings\pklocke\My
Documents\4-Sourcing\Spreadsheets\Pareto\test.ppt"
.Close
End With

PPApp.Quit

Set PPSlide = Nothing
Set PPPres = Nothing
Set PPApp = Nothing

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
excel chart export error runtime 1004 Mau Charts and Charting in Excel 3 August 17th 05 11:35 AM
excel chart export error runtime 1004 Mau[_2_] Excel Programming 0 August 4th 05 09:53 PM
Excel 2003 Macro Error - Runtime error 1004 Cow Excel Discussion (Misc queries) 2 June 7th 05 01:40 PM
Excel chart in Powerpoint Chris Charts and Charting in Excel 2 December 10th 04 01:19 PM
moving excel objects pasted as an image in Powerpoint Iker Excel Programming 1 September 24th 04 04:39 AM


All times are GMT +1. The time now is 06:48 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"