1
votes

I'm writing a PowerPoint macro that opens a Word document and imports every picture in the document to its own slide. Because I can't place the Word InlineShape objects directly in PowerPoint, apparently, I'm using the clipboard. The relevant code is:

Dim wdApp As Object
Dim SourceDoc As Document
Dim TargetSlide As Slide
Dim Figures As Word.InlineShapes
Dim Figure As Word.InlineShape
Dim TargetShapeRange As ShapeRange

Set wdApp = CreateObject("Word.Application")
Set SourceDoc = wdApp.Documents.Open(FileName:=PathToFile, ReadOnly:=True)
Set Figures = SourceDoc.InlineShapes

For Each Figure In Figures
    Figure.Range.Select
    Figure.Application.Selection.Copy
    Set TargetSlide = ActivePresentation.Slides.AddSlide(ActivePresentation.Slides.Count + 1, _
      ActivePresentation.SlideMaster.CustomLayouts(6))
    Set TargetShapeRange = TargetSlide.Shapes.Paste
Next Figure

With PowerPoint 2010 and Word 2010, this works perfectly. In PowerPoint 2013 (with Word 2013 installed, and referencing the Microsoft Word 15.0 Object Library rather than 14.0), the Set TargetShapeRange = TargetSlide.Shapes.Paste line gives me run-time error '-2147188160 (80048240)':

Shapes (unknown member): Invalid request. Clipboard is empty or contains data which may not be pasted here.

I've tried using the Copy and CopyAsPicture methods on both the Selection and Range objects. I've tried using the Shapes.PasteSpecial command. I've tried several different ways of accessing the Word Application object. Nothing works.

Notably, if I modify the code to copy the preceding paragraph of text in addition to the picture, the script works—it retrieves the text, but not the picture.

1

1 Answers

0
votes

I know this question is almost two years old but I found this through google after having a similar issue so I'll post this here.

Try

Figure.Application.ActiveWindow.ScrollIntoView Selection.Range, True

right before copying. It works for me even with screenupdating disabled or if the application is not visible.