LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Copy Excel chart to PPT that is already open

Usually get object if a filename which is the 1st parameter

set PPApp = getobject("c:\temp\abc.ppt")

The 2nd parameter is the application.

"Tony Bender" wrote:

On Sep 25, 10:27 pm, Joel wrote:
I made a couple of changes to get the code to run. I not sure what you are
trying to do. I went to the power point VBA help and didn't find a RUN
method. I did find a RUNS method and here is an example of that instruction.
I didn't know the slide number or object that yhou are using.

With Application.ActivePresentation.Slides(1).Shapes(2) _
.TextFrame.TextRange
With .Runs(2).Font
If .Italic Then
.Bold = True
End If
End With
End With

Sub OpenPPT()
Dim PPApp As PowerPoint.Application
Dim PPPres As PowerPoint.Presentation

'Get existing instance of PP if it's open; otherwise create a new one

On Error Resume Next

Set PPApp = GetObject(, "PowerPoint.Application") '<added comma
If Err Then
Set PPApp = New PowerPoint.Application
PPApp.Visible = msoTrue '<made application visible
Set PPPres = PPApp.Presentations.Open("C:\temp\slide 1.ppt")
Else

Set PPPres = PPApp.Presentations("slide 1.ppt")

End If

On Error GoTo 0

'******Runs macro in PPT that copies data from excel and
'pastes onto PPT slides
PPApp.Run (1)

End Sub



"Tony Bender" wrote:
Joel,


Thanks for this, but it didn't work.
I got a Run-time error 91 "Object variable or With Block variable not
set" and when I clicked Debug it highlighted this line:


PPApp.Run (PPPres.Name & "!AddPieChart")


When I remove this line the macro doesn't do anything.
TB- Hide quoted text -


- Show quoted text -


Joel,

Thank you so much for your help with this. It works fine now.

I am curious though how adding the comma made the difference.

Set PPApp = GetObject(, "PowerPoint.Application") '<added comma

Thanks again for your help.

Tony



 
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
copy chart formatting and chart templates in Excel 2007 Astelix Charts and Charting in Excel 4 March 4th 10 04:10 AM
From excel - open word doc and copy form field contents to excel c gnome88 Excel Programming 0 July 25th 05 11:45 PM
Why does excel create a copy of the worksheet i open Renee Excel Discussion (Misc queries) 4 March 2nd 05 06:17 PM
i can't open excel workbook if it has a chart in it! Aidan Excel Discussion (Misc queries) 2 February 2nd 05 09:37 AM
Excel 2003 Workbooks.Open with CorruptLoad=xlRepairFile fails on Excel 5.0/95 file due to Chart, with Error 1004 Method 'Open' of object 'Workbooks' failed Frank Jones Excel Programming 2 June 15th 04 03:21 AM


All times are GMT +1. The time now is 11:21 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"