``` Microsoft.Office.Interop.Visio.Document currentStencil = axDrawingControl1.Document.Application.Documents.OpenEx(System.Windows.Forms.Application.StartupPath + "\\Visio模具\\模具.vssx", (short)Microsoft.Office.Interop.Visio.VisOpenSaveArgs.visOpenHidden);
//關閉隱藏“形狀搜索”面板(非常重要)
Microsoft.Office.Interop.Visio.Window winShapeSearch = axDrawingControl1.Window.Windows.get_ItemFromID((int)Microsoft.Office.Interop.Visio.VisWinTypes.visWinIDShapeSearch);
winShapeSearch.Close();
Hashtable hashtableType = new Hashtable();
hashtableType = ToolsUtil.GetModelDiagramNodeType(modelDiagramSetConfig);
string strMastersNodeType = (string)hashtableType["19"];
Microsoft.Office.Interop.Visio.Shape shape = currentPage.Drop(currentStencil.Masters[strMastersNodeType], dNodeWidth, dNodeHeight);
if (shape != null && shape.ID > 0)
{
shape.Name = paramHashtable["NewLocalNodeID"].ToString();
shape.Data2 = "19";
shape.Data3 = "區域活動節點";
shape.Text = paramHashtable["NodeName"].ToString() + "!!!";
visioApplication.ActiveWindow.Page.Shapes.ItemFromID(shape.ID).CellsSRC(VisSectionIndices.visSectionCharacter, 0, VisCellIndices.visCharacterColor).FormulaU = "2";
}
```
以下是報錯:
CalloutTarget = “((Microsoft.Office.Interop.Visio.ShapeClass)shape).CalloutTarget”引發了型別“System.Runtime.InteropServices.COMException”的例外
Data1 = “((Microsoft.Office.Interop.Visio.ShapeClass)shape).Data1”引發了型別“System.Runtime.InteropServices.COMException”的例外
。。。。。。。。
所有的這些都報錯了,整個shape
當運行到 Microsoft.Office.Interop.Visio.Shape shape = currentPage.Drop(currentStencil.Masters[strMastersNodeType], dNodeWidth, dNodeHeight);這句話的時候,shape里面的屬性方法各種例外
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/26224.html
標籤:C#
