本文介绍了无法取消对SmartArt Shape的分组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试从代码中取消对SmartArt形状的分组,但始终会导致错误:此成员只能在组中访问".

I try to ungroup a SmartArt shape from code, but it always causes an error: "This member can only be accessed for a group".

但是,如果我右键单击SmartArt形状并将其取消分组,它就可以正常工作.

However, it's working, if I right click on the SmartArt shape, and ungroup it.

我该如何解决?

我的代码是:

公共无效CreateSmartArt(PowerPoint.Shapes allShapes)

public void CreateSmartArt(PowerPoint.Shapes allShapes)

{

        PowerPoint. Shape smartartShape = allShapes.AddSmartArt( IttPowerPoint .Instance.PowerPointApp.SmartArtLayouts ["MyLayOut" ],0f,0f,宽度,高度);

        PowerPoint.Shape smartartShape = allShapes.AddSmartArt(IttPowerPoint.Instance.PowerPointApp.SmartArtLayouts["MyLayOut"], 0f, 0f, width, height);

       元帅 .ReleaseComObject(smartartShape); smartartShape = null ;

        Marshal.ReleaseComObject(smartartShape); smartartShape =null;

}

公共无效UngroupSmartArt(PowerPoint.Shape形状)

Public void UngroupSmartArt(PowerPoint.Shape shape)

{

       尝试

        try

        {

        {

                  shape.Ungroup();

                 shape.Ungroup();

        }

        }

       捕获(异常除外)

        catch (Exception ex)

        {

       {

                  MessageBox .Show(ex.Message);

                 MessageBox.Show(ex.Message);

       }

       }

}

推荐答案

我建议首先检查Shape类的Type属性,例如:

I'd suggest checking the Type property of the Shape class first, for example:

For Each s In myDocument.Shapes
    If s.Type = msoGroup Then s.Ungroup
Next


这篇关于无法取消对SmartArt Shape的分组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-25 01:38