VBA Macro: Paste Excel Cells to PPT Slides, paste limit?!

mlex

New Member
Joined
Jun 15, 2011
Messages
4
Hello everyone,

I have Microsoft Office 2003 and Windows Vista. I'm a relative VBA newbie, but I have been experimenting with copying individual cells in Excel to individual PowerPoint slides via a macro. No matter how many individual cells I copy to individual slides, and no matter what order the copying takes place, there seems to be a limit of 248 cells that are copied. It is not dependent on how much text is in each copied cell. The macro pretends to copy each cell to a new slide (I can see PowerPoint creating a new slide for every copied cell), but when I go to look at the finished PowerPoint file that has been created, only 248 of the slides actually contain the pasted material and the rest are blank.

Here is the code I am running:

Code:
Sub Pastetoppt ()

' Start PowerPoint.
    Dim ppApp As PowerPoint.Application
    Set ppApp = CreateObject("Powerpoint.Application")

' Make it visible.
    ppApp.Visible = True
  
' Add a new presentation.
    Dim ppPres As PowerPoint.Presentation
    Set ppPres = ppApp.Presentations.Add(msoTrue)

' Add new slide.
    Dim ppSlide As PowerPoint.Slide
    Set ppSlide = ppPres.Slides.Add(Index:=1, Layout:=ppLayoutText)

' Find coordinates of last cell in range.
    Dim lastrow As Integer
    Dim lastcol As Integer
    lastrow = Cells.Find(What:="*", After:=[A1],    SearchDirection:=xlPrevious).row
    lastcol = Cells.Find(What:="*", After:=[A1], SearchDirection:=xlPrevious).Column

Dim rng As Range
Dim row As Range
Dim cell As Range

Set rng = Range(Cells(1, 1), Cells(lastrow, lastcol))

For Each row In rng.Rows
For Each cell In row.Cells
    cell.Select
    Selection.Copy
   
    Dim ppSlide2 As PowerPoint.Slide
    Dim x As Integer
    x = ppPres.Slides.Count
    Set ppSlide2 = ppPres.Slides.Add(Index:=x, Layout:=ppLayoutText)
        ppApp.ActivePresentation.Slides(x).Select
        ppApp.ActiveWindow.Selection.SlideRange.Shapes("Rectangle 2").Select
        ppApp.ActiveWindow.Selection.TextRange.Paste
 
Next cell
Next row

End Sub
I would be very grateful for some help on this!

:bow:
ML
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Update. It's very interesting that if I export the same cell data to word and then do "Send to Powerpoint" PowerPoint only allows a maximum of 249 slides to be created and states "The outline is too long to read in it's entirety".

I read about the same problem here: http://www.officekb.com/Uwe/Forum.a...lides-when-sending-Word-outline-to-PowerPoint

So I think this limit of 248/249 slides is somehow part of PowerPoint. Does anybody know how to change it?

Thank you,
ML
 
Upvote 0

Forum statistics

Threads
1,223,101
Messages
6,170,116
Members
452,302
Latest member
TaMere

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top