我有一些 VBA 代码将 EPS 图片插入到 PowerPoint 幻灯片中,如下所示:
Function InsertPicture(filename as String) As Shape
Dim curSlide As Integer
Dim oShp As Shape, gShp As Shape
curSlide = ActiveWindow.View.Slide.SlideIndex
With ActivePresentation.Slides(curSlide).Shapes
Set oShp = .AddPicture(filename, msoFalse, msoTrue, 0, 0)
' Convert (by ungrouping) from EPS to Microsoft Office drawing object
oShp.Ungroup.Name = "GroupEPS"
' Return the new Microsoft Office drawing object
Set InsertPicture = ActivePresentation.Slides(curSlide).Shapes("GroupEPS")
End With
End Sub
Excel的等效插入图片功能是这样的:
ActiveSheet.Pictures.Insert(filename).Select
或者,如果需要对对象的引用:
Dim oPic as Object
Set oPic = ActiveSheet.Pictures.Insert(filename)
但是当我尝试使用以下行取消组合时,我收到错误 438“对象不支持此属性或方法”
' For a selection
Selection.Ungroup
' For an object
oPic.Ungroup.Name = "GroupEPS"
但是,如果我右键单击正确插入工作表的图片,我可以在确认转换为 Microsoft Office 绘图对象后成功取消组合。
为什么 UI 允许取消分组但 Excel VBA 不允许(而 PowerPoint VBA 允许),有没有办法解决这个问题?