ppt2007 Shapes.Paste

A

Andy Pope

Hi,

Using the shapes.paste method now generates an error in ppt2007. Does
anybody know a work around?

The following works fine in 2003.

Copy some text to the clipboard.
Open a new presentation
ATL+F11 (open VBE)
CTRL+G (open immediate window)
activepresentation.Slides(1).Shapes.Paste

A textbox will be added to the slide, as expected.
Now repeat but for ppt 2007 and the follow error occurs.

Run-time error '-2147188160 (80048240)'
Shapes (unknown member): Invalid request. Clipboard empty or contains
data which may not be pasted here.

The clipboard is not empty to and if I do CTRL+V the shape and text
appear as expected.

Any enlightening information appreciated.

Cheers
Andy
 
A

Andy Pope

Hi Steve,

Thanks for the work around. Looks like coding in 2007 is a minefield,
trying to guess the object model and creative thinking on work arounds.

To be honest I have not done much with 2007 code wise, I always use
2003. But I guess at some point clients will want the shining new thing
in 2007. Let's hope that MS has fixed the plumbing by then ;)

Cheers
Andy
 
A

Andy Pope

Edit: Posted again as it did not appear in the NGs.

Hi,

If you are pasting a range I assume you want the result as a table in
powerpoint. In which case you need to create a dummy table first and then
paste each cell.

Sub xx()
Dim ObjPPAPP As New PowerPoint.Application
Dim objPPPres As PowerPoint.Presentation
Dim objPPSlide As PowerPoint.Slide
Dim pptTempTable As PowerPoint.Table
Dim rngCopy As Range
Dim lngRow As Long
Dim lngCol As Long

Set ObjPPAPP = New PowerPoint.Application
ObjPPAPP.Visible = True
Set objPPPres = ObjPPAPP.Presentations.Open("C:\Production
Template.ppt")
Set objPPSlide =
objPPPres.Slides(ObjPPAPP.ActiveWindow.Selection.SlideRange.SlideIndex)

Set rngCopy = Range("A1:E4")

With objPPSlide
With .Shapes.AddTable(rngCopy.Rows.Count, rngCopy.Columns.Count, 2,
120, 715, -1)
For lngRow = 1 To rngCopy.Rows.Count
For lngCol = 1 To rngCopy.Columns.Count
rngCopy.Cells(lngRow, lngCol).Copy
.Table.Cell(lngRow,
lngCol).Shape.TextFrame.TextRange.Characters.Paste
Next
Next
End With

End With
End Sub

You will also need to format the table if the default formatting is not
suitable.

Cheers
Andy
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top