未处理的ComException连接形状

时间:2014-08-22 09:07:40

标签: c# excel charts shape

我想创建一个Group to Picture and Textbox和Straight Arrow Connector。

我的代码有错误HRESULT: 0x800A03EC (ComException was unhandled)

ShapeRange shapeRange;
List<object> shapeArray = new List<object>();

Shape picture = worksheet.Shapes.AddPicture(imageResultYearFiles[y], 
                Microsoft.Office.Core.MsoTriState.msoFalse,
                Microsoft.Office.Core.MsoTriState.msoCTrue,
                xAxis, yAxis, 135, 100);

Shape textBox = worksheet.Shapes.AddTextbox(
                    Microsoft.Office.Core.MsoTextOrientation.msoTextOrientationHorizontal,
                    xAxis + 48, yAxis - 30, 37, 21);

Shape c2 = worksheet.Shapes.AddConnector(
                Microsoft.Office.Core.MsoConnectorType.msoConnectorStraight,
                tAxis2.leftX, tAxis1.rightY, (tAxis1.rightX - tAxis2.leftX) / 2,
                (tAxis1.rightX - tAxis1.rightY) / 2);

c2.ConnectorFormat.BeginConnect(gene_textBox, 2);
c2.ConnectorFormat.EndConnect(shape2,4); 

shapeArray.Add(picture1.Name);   
shapeArray.Add(picture2.Name);
shapeArray.Add(textBox.Name);  
shapeArray.Add(c1.Name);
shapeArray.Add(c2 .Name);

if (shapeArray.Count > 1)
{
    shapeRange = worksheet.Shapes.get_Range(shapeArray.ToArray());
    shapeRange.Group();  // <-- Error
}

为什么代码有错误HRESULT: 0x800A03EC (ComException was unhandled)

0 个答案:

没有答案
相关问题