I have a macro that gets a shape from one slide by its unique tag properties and then pastes it to another slide.
It works as expected on many different versions of OS (Win 7, 8, 8.1) and versions of PowerPoint (2007, 2010, 2013, 32 & 64 bit).
But, I just had one user where the paste command fails due to the clipboard being empty.
This is the code snippet (I haven't included the ShapeByTag) function which returns a shape, for simplicity reasons:
Dim oShp as ShapeRange
ShapeByTag(TagName, TagValue).Copy
Set oShp = oSld.Shapes.Paste
When the error occurs on the second line "-2147188160 Shapes (unknown member) : Invalid request. Clipboard is empty or contains data which may not be pasted here." I can enter the VBE and rerun the command successfully, indicating to me that there is a timing issue.
But the user's machine is a brand new i5 Windows 8.1 Pro (64 bit) laptop with 8GBRAM which is more powerful that many other user machines where the issue does not occur. He's using PowerPoint 2013 32 bit.
I can overcome the problem by doing this:
Dim oShp as ShapeRange
ShapeByTag(TagName, TagValue).Copy
On Error Resume Next
RetryPaste:
Set oShp = oSld.Shapes.Paste
If Err <> 0 Then Err.Clear: GoTo RetryPaste
On Error Goto 0
But why is the error occurring in the first place? I would have expected that the .Copy method would be pretty instant and that the following line wouldn't execute until the underlying OS had completed the copy operation. I'm also going to add a Timer to see how long a delay is actually being injected.