PowerPoint 2007 Shapes.Paste

  • Thread starter Thread starter stricky
  • Start date Start date
S

stricky

Hi,

I have been converting our office VB6 Programs to use Office 2007.

One of Our Applications uses powerpoint to display information
transferred from a RTF document. Upon Attempting to Paste onto a slide
i have issues.

When you Paste the Normal Way using
ActiveDocument.Slides(ActiveDocument.Slides.Count).Paste the content
of the Clipboard is pasted for the First Slide only.

When you use this method to paste to the second slide you get a Object
not recognised error for Shapes. In This Context the PasteSpecial
Command does not work either.

To get this to work i Needed to add a Shape to the Slide to initialise
the Slide Shapes Object, Then Paste is still not available but
PasteSpecial Is.
From a Developers perspective this is very irratating as the option is
available via IntelliSense but it does not work.

regards,

Stuart Dodd BSc
 
One of Our Applications uses powerpoint to display information
transferred from a RTF document. Upon Attempting to Paste onto a slide
i have issues.

When you Paste the Normal Way using
ActiveDocument.Slides(ActiveDocument.Slides.Count).Paste the content
of the Clipboard is pasted for the First Slide only.

There's no ActiveDocument object in PPT. You'd want to use ActivePresentation
instead in both places. From VBA in PPT this works as expected.
When you use this method to paste to the second slide you get a Object
not recognised error for Shapes. In This Context the PasteSpecial
Command does not work either.

Given that the code above shouldn't work at all, it's hard to say what's going
on. If changing it to ActivePresentation doesn't help, post the relevant code
here, if you can.
 
Appologies, Yeah the code above should not work should be

ActivePresentation.Slides(ActivePresentation.Slides.Count).Shapes.Paste

the paste opewration is to place a complex drawing object that has
been Grouped.

Which produces the error in VBA, and when set to a Slide object in VB6
the error also appears.

regards,

Stu
 
Stricky said:
Appologies, Yeah the code above should not work should be

ActivePresentation.Slides(ActivePresentation.Slides.Count).Shapes.Paste

the paste opewration is to place a complex drawing object that has
been Grouped.

Which produces the error in VBA, and when set to a Slide object in VB6
the error also appears.

Again, can you post more of the code than just the line that fails? Sometimes
the context is key.
 
oTemp.Content.WholeStory
oTemp.Content.ShapeRange.Select
If (iCount Mod 50) = 0 Then
oPresentation.Close
Set oPresentation = m_objPPT.Presentations.Add
oPresentation.PageSetup.SlideHeight =
oDoc.PageSetup.PageHeight
oPresentation.PageSetup.SlideWidth =
oDoc.PageSetup.PageWidth
oPresentation.PageSetup.SlideOrientation =
oDoc.PageSetup.Orientation
oPresentation.SaveAs Replace(m_sRtfPath, ".rtf", "_" &
iCount & ".ppt")
ReDim Preserve
aryPresentations(UBound(aryPresentations) + 1)
aryPresentations(UBound(aryPresentations)) =
Replace(m_sRtfPath, ".rtf", "_" & iCount & ".ppt")
'Set oPresentation =
m_objPPT.Presentations.Open(Replace(m_sRtfPath, ".rtf", ".ppt"))
End If
m_objWord.Selection.ShapeRange.Group
oTemp.UndoClear
With oTemp
.Content.ShapeRange.Select
End With
'oTemp.ActiveWindow.View.ShowDrawings = True
If iCount <> 1 Then m_objWord.Selection.WholeStory

Clipboard.Clear
m_objWord.Selection.Cut

'# Add picture to a new slide in the presentation
Set oSlide =
oPresentation.Slides.Add(oPresentation.Slides.Count + 1,
ppLayoutBlank)
oSlide.Name = "Page : " & iCount
oSlide.Select

oSlide.Shapes.Paste

The last line is the issue, Though i did find a way round it it's not
pleasant so would appreciate a way round it.

I can't paste any more than this. Like i said before the Word document
id a drawing object with a complex drawing per page.

Stu
 
Stricky said:
oTemp.Content.WholeStory
oTemp.Content.ShapeRange.Select
If (iCount Mod 50) = 0 Then
oPresentation.Close
Set oPresentation = m_objPPT.Presentations.Add
oPresentation.PageSetup.SlideHeight =
oDoc.PageSetup.PageHeight
oPresentation.PageSetup.SlideWidth =
oDoc.PageSetup.PageWidth
oPresentation.PageSetup.SlideOrientation =
oDoc.PageSetup.Orientation
oPresentation.SaveAs Replace(m_sRtfPath, ".rtf", "_" &
iCount & ".ppt")
ReDim Preserve
aryPresentations(UBound(aryPresentations) + 1)
aryPresentations(UBound(aryPresentations)) =
Replace(m_sRtfPath, ".rtf", "_" & iCount & ".ppt")
'Set oPresentation =
m_objPPT.Presentations.Open(Replace(m_sRtfPath, ".rtf", ".ppt"))
End If
m_objWord.Selection.ShapeRange.Group
oTemp.UndoClear
With oTemp
.Content.ShapeRange.Select
End With
'oTemp.ActiveWindow.View.ShowDrawings = True
If iCount <> 1 Then m_objWord.Selection.WholeStory

Clipboard.Clear
m_objWord.Selection.Cut

'# Add picture to a new slide in the presentation
Set oSlide =
oPresentation.Slides.Add(oPresentation.Slides.Count + 1,
ppLayoutBlank)
oSlide.Name = "Page : " & iCount
oSlide.Select

oSlide.Shapes.Paste

The last line is the issue, Though i did find a way round it it's not
pleasant so would appreciate a way round it.

I can't paste any more than this. Like i said before the Word document
id a drawing object with a complex drawing per page.


I can't see anything wrong with what you're doing here, but have you tried it
with simpler drawings in the Word file? Or simplify the problem a bit ... copy
one of the Word selections to the clipboard then try this in PPT

Sub Test()
Dim oSlide As Slide
Dim oPresentation As Presentation
Dim x As Long
Set oPresentation = ActivePresentation

For x = 1 To 10
Set oSlide = oPresentation.Slides.Add(oPresentation.Slides.Count + 1,
ppLayoutBlank)
oSlide.Name = "Page : " & CStr(x)
oSlide.Select
oSlide.Shapes.Paste
Next

End Sub
 
hi steve,

had already tried this approach and it only works for the first slide
in the presentation as soon as you move to the second slide the
Shapes.Paste line does not work.

regards,

Stu
 
Stricky said:
hi steve,

had already tried this approach and it only works for the first slide
in the presentation as soon as you move to the second slide the
Shapes.Paste line does not work.

regards,

Stu


Has me beat then, I'm afraid. You've tried this with multiple files on
multiple computers, though?
 
Thanks Anyway Steve,

FYI the workaround i have developed is to

If oPresentation.Slides.Count = 1 Then
oSlide.Shapes.Paste
Else
oSlide.Shapes.AddShape(msoShape10pointStar, 10, 10, 50, 50).Select
oSlide.Shapes.PasteSpecial ppPasteMetafilePicture
End If

If iCount <> 1 Then
oPresentation.Slides(oPresentation.Slides.Count).Shapes(1).Delete
End If

I have to paste as a metafile picture so the picture can be broken
apart the same as a complex drawing object that has been grouped.

hope this helps if anyone else comes accross this issue.

Regards,

Stuart Dodd BSc
 
Stricky said:
Thanks Anyway Steve,

No problem ...

An alternate to your workaround might be faster and easier to work with btw:

Dim oSh as Shape
Dim oTempSh as Shape
' from VB6, you might need to dim it as PowerPoint.Shape if you've
' set a reference to PPT or as Object if not

If oPresentation.Slides.Count = 1 Then
set oSh = oSlide.Shapes.Paste(1)
Else
set oTempSh = oSlide.Shapes.AddShape(msoShape10pointStar, _
10, 10, 50, 50)
set oSh = oSlide.Shapes.PasteSpecial ppPasteMetafilePicture
End If

If Not oTempSh Is Nothing Then
oTempSh.Delete
End If
 
Back
Top