Question

I migrated a VBA macro from PowerPoint 2007 to 2010 and after some debugging and testing I found out that copying shapes from one presentation to another only works under Windows 7 and not under Windows XP.

When I close the presentation I copied the shape from, in Windows XP, the new object is emptied. In Windows 7 the object still exists.

I made an example:

Public Sub test()
  Dim HandlerApplication As New HandlerApplication
  Dim slide As slide

  HandlerApplication.create Application
  Set slide = ActiveWindow.Selection.SlideRange(1)

  Dim ppt As Presentation
  Dim shapeToCopy As shape
  Dim copiedShape As shape
  Dim strTemplateFile As String
  strTemplateFile = "SlideTemplate.pptx"

  Set ppt = Application.Presentations.Open(BuildPath(ComponentsPath, strTemplateFile), msoTrue, msoFalse, msoFalse)
  Set shapeToCopy = ppt.slides(7).shapes(1)

  shapeToCopy.Copy
  Set copiedShape = slide.shapes.PasteSpecial(ppPasteShape)(1)
  ppt.Close
  copiedShape.Name = "TestName"
End Sub

I appreciate any help/workaround.

Was it helpful?

Solution

The problem was a bug in Office 2010 and has been fixed in this hotfix: http://support.microsoft.com/kb/2345341

OTHER TIPS

Try shapeToCopy.Duplicate instead.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top