Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
excel chart export error runtime 1004 | Charts and Charting in Excel | |||
excel chart export error runtime 1004 | Excel Programming | |||
Excel 2003 Macro Error - Runtime error 1004 | Excel Discussion (Misc queries) | |||
Excel chart in Powerpoint | Charts and Charting in Excel | |||
moving excel objects pasted as an image in Powerpoint | Excel Programming |