Error: “The specified data type is unavailable” When pasting Shapes as PNG format in PowerPoint

核能气质少年 提交于 2019-12-06 05:28:11

I get this error in PPT 2010: "Shapes (unknown member) : Invalid request. Clipboard is empty or contains data which may not be pasted here."

We both notice there is "Shape 125" when you zoom out or use the Selection Pane:

After a lot of trial and error (I thought the nesting might be a problem, and tried to un-nest them -- successfully, but the error still happened) I noticed that each of them had a height of 0. If I changed that to any positive value, success!

So here is the fix -- call a new function to make sure shapes have height > 0:

    For Each oSh In oSl.Shapes
        ' modify the following depending on what you want to
        ' convert
        Select Case oSh.Type
            Case msoGroup
                'Ensure each grouped shape has h/w of at least "1"
                FixShape oSh
                ConvertPicToPNG oSh
            Case Else

Here is the function:

Function FixShape(ByRef oSh As Shape)

Dim s As Shape
'## Iterate the GroupItems collection and ensure minimum height/width
'   for converion to png/jpg/etc.
For Each s In oSh.GroupItems
    If s.Height = 0 Then s.Height = 1
    If s.Width = 0 Then s.Width = 1
    'Recursive
    If s.Type = msoGroup Then
        Set s = FixShape(s)
    End If
Next

Set FixShape = oSh

End Function

Here is the final output which converts the shapes to PNG:

Root Cause of this Error

It seems you are not able to paste shapes with height/width of 0, as PNG format (although you can paste them as Shapes). This seems to be an intentional limitation, but unfortunately the error message is ambiguous.

Solution to this Error

Ensure that shapes have minimum dimensions of 1x1 before trying to paste as an image format (PNG, JPG, etc.)

While you were able to resolve the problem by deleting the offending shape, this should help you so that you don't have to search for those off-pane shapes or try to troubleshoot this again in the future.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!