PDA

View Full Version : To Convert Excel to PPT



abiram01
04-27-2006, 02:10 AM
Hi all,

I want to convert an excel workbook to ppt using Excel VBA.Please let me know how to accomplish this.


Thanks & Regards,
Abhi ram

OBP
04-27-2006, 03:11 AM
Can I ask why you would want to do this rather than just "linking" ppt to the Excel workbook?

abiram01
04-27-2006, 03:28 AM
Can I ask why you would want to do this rather than just "linking" ppt to the Excel workbook?

If I link the PPT to excel, then i need to double click the charts in ppt to update them if am correct.

So if i can convert the xls to ppt then I thought it will be ok..

Please let me know if there is any method to accomplish this.

OBP
04-27-2006, 03:38 AM
I always used to do all of the updating in Excel, which is then automatically picked up by ppt via the link.
I do not know of any way to convert to ppt, you certainly do not appear to be able to "save as".
Perhaps someone else with more VB experiance can help.
If you do not get any other responses I would suggest a private mail to Firefyter.

abiram01
04-27-2006, 03:51 AM
I always used to do all of the updating in Excel, which is then automatically picked up by ppt via the link.
I do not know of any way to convert to ppt, you certainly do not appear to be able to "save as".
Perhaps someone else with more VB experiance can help.
If you do not get any other responses I would suggest a private mail to Firefyter.

Thanks. I will let you know if dont get any responses.

Regards,
Abhi Ram

Marcster
04-27-2006, 04:27 AM
Does this thread help?:

http://www.vbaexpress.com/forum/showthread.php?t=7012

Marcster.

brettdj
04-27-2006, 04:43 AM
You can export graphs from PP to excel (linked or as a picture) with this kb article
http://vbaexpress.com/kb/getarticle.php?kb_id=370

Cheers

Dave

Killian
04-27-2006, 05:33 AM
I think you might want to define the requirement in a little more detail.
You can to go though each collection of objects on a sheet (charts, shapes, etc) and copy/paste them across to a PowerPoint slide (as suggested, paste-linking the charts would mean you can still update them in Excel). The used ranges could also be checked and put in PowerPoint as tables.
You'd have to decide how to define the layout of the page but in principle, it's do-able with something likeDim ws As Worksheet
Dim appPPT As PowerPoint.Application
Dim pptPres As PowerPoint.Presentation
Dim pptSld As PowerPoint.Slide
Dim shp As Shape

Set appPPT = New PowerPoint.Application
Set pptPres = appPPT.Presentations.Add

For Each ws In ActiveWorkbook.Sheets
' add a slide
Set pptSld = pptPres.Slides.Add(pptPres.Slides.Count + 1, ppLayoutTitleOnly)
' update the title
With pptSld.Shapes.Placeholders
If .Count > 0 Then
With .Item(1)
If .PlaceholderFormat.Type = ppPlaceholderTitle Then
.TextFrame.TextRange = ws.Name
End If
End With
End If
End With
' copy/paste over the shapes
For Each shp In ws.Shapes
shp.Copy
pptSld.Shapes.Paste
' to do - scale & position shape here
Next shp

'copy paste ranges?

Next ws

' to do - save here

Set pptSld = Nothing
Set pptPres = Nothing
Set appPPT = Nothing

abiram01
04-27-2006, 05:41 AM
I think you might want to define the requirement in a little more detail.
You can to go though each collection of objects on a sheet (charts, shapes, etc) and copy/paste them across to a PowerPoint slide (as suggested, paste-linking the charts would mean you can still update them in Excel). The used ranges could also be checked and put in PowerPoint as tables.
You'd have to decide how to define the layout of the page but in principle, it's do-able with something likeDim ws As Worksheet
Dim appPPT As PowerPoint.Application
Dim pptPres As PowerPoint.Presentation
Dim pptSld As PowerPoint.Slide
Dim shp As Shape

Set appPPT = New PowerPoint.Application
Set pptPres = appPPT.Presentations.Add

For Each ws In ActiveWorkbook.Sheets
' add a slide
Set pptSld = pptPres.Slides.Add(pptPres.Slides.Count + 1, ppLayoutTitleOnly)
' update the title
With pptSld.Shapes.Placeholders
If .Count > 0 Then
With .Item(1)
If .PlaceholderFormat.Type = ppPlaceholderTitle Then
.TextFrame.TextRange = ws.Name
End If
End With
End If
End With
' copy/paste over the shapes
For Each shp In ws.Shapes
shp.Copy
pptSld.Shapes.Paste
' to do - scale & position shape here
Next shp

'copy paste ranges?

Next ws

' to do - save here

Set pptSld = Nothing
Set pptPres = Nothing
Set appPPT = Nothing

Hi ,

This is want am looking for.. but can I select more than one shape at a time?

Thanks & Regards,
Abhi Ram

Killian
04-27-2006, 06:49 AM
You can. I've assumed an automated process, so this code goes through each shape in turn. You can test the shape to find it's type and decide whether you want to copy/paste it or not.
To do it all in one go, you could build a list of each shape you want, group them and copy/paste the group - although you can add things to the selection object easily enough' copy/paste over the shapes
For Each shp In ws.Shapes
If shp.Type = msoChart Then
'add charts only to the selection
shp.Select False
End If
Selection.Copy
pptSld.Shapes.Paste
Next shp