Inserting charts in PPT (1 Viewer)

lambuhere1

Registered User.
Local time
Today, 00:44
Joined
Nov 19, 2001
Messages
28
Hi

I am a new bie to VBA. I wanted to write some code in PPT. What I am trying to do is to get the powerpoint open Excel application and open the workbook located in c:\ramp.xls and then copy the chart 1 into the present slide of the Powerpoint. The slide is blank. Whenever I use the following code, I get error. Runtime one. Can anyone tell me why ?

Sub xlchartpastespecial()
Dim xlapp As Object
Dim xlwrkbook As Object
Dim currslide As Long

Set xlapp = CreateObject("Excel.application")

Set xlwrkbook = xlapp.workbooks.Open("C:\Documents and Settings\janakira\My Documents\FSNL2_9H\spacer34_plots.xls")

xlworkbook.Charts("Chart1").chartobjects(1).CopyPicture

currslide = ActiveWindow.Selection.SlideRange.SlideNumber

ActivePresentation.Slides(currslide).Shapes.Paste

xlwrkbook.Close (False)
xlapp.Quit

Set xlapp = Nothing
Set xlwrkbook = Nothing

End Sub

By the way, Can anyone guide me with respect to any books on PPT VBA?

Thanks and regards

Ram P
 

jesseb

Registered User.
Local time
Today, 00:44
Joined
Jan 8, 2002
Messages
32
This might set you off on the right foot:

you should go to Tools and then References in the VB editor and add the Excel Object.

Then create a variable like

dim variable as application

set variable = (powerpoint.application) ~ I am not sure about that but it is something similar.

Then you can use the open and copy commands.

In order to open the file you have to run the
freefilenum thing (use the VB help to figure that out). Hope this is some help.

[This message has been edited by jesseb (edited 01-12-2002).]
 

lambuhere1

Registered User.
Local time
Today, 00:44
Joined
Nov 19, 2001
Messages
28
Hey

Thanks for the idea.. i shall give it a shot.

Regards

Ram P
 

Users who are viewing this thread

Top Bottom