Fail to edit Attribute text in Visio UML Class shape from C# code

H

Hardolf

I have a problem inserting or modifying e.g. Attributes in a Class shape from
C#, using the Visio 11 COM Type Library. I get this message:

An unhandled exception of type 'System.Runtime.InteropServices.COMException'
occurred in VisioUML.exe
Additional information:
Requested operation is presently disabled.

This is my sample code:

Microsoft.Office.Interop.Visio.Application m_VApp = new
Microsoft.Office.Interop.Visio.ApplicationClass();
Microsoft.Office.Interop.Visio.Document m_VDoc =
m_VApp.Documents.Open(sExeDir + @"..\..\Drawing1.vsd");
Microsoft.Office.Interop.Visio.Page m_VPage = m_VDoc.Pages["Static Structure
- Test"];
Microsoft.Office.Interop.Visio.Document m_VMDoc =
m_VApp.Documents["UMLSTR_M.VSS"];

Microsoft.Office.Interop.Visio.Master mstDrop =
m_VMDoc.Masters.get_ItemU("Class");
Microsoft.Office.Interop.Visio.Shape vNewShp = m_VPage.Drop(mstDrop, 2.5,
5.5);

Microsoft.Office.Interop.Visio.Shape vName = vNewShp.Shapes["Name"];
vName.Text = "Hello"; // OK

Microsoft.Office.Interop.Visio.Shape vAtt = vNewShp.Shapes["Attributes"];
vAtt.Text = "Hellooo"; // *** FAILED ***

Have you any suggestions?
Regards, Hardolf
 
H

Hardolf

I just found the answer myself:

The Class shape has Attributes and Operations shapes inside it.
When the sub-shape was right-clicked, selecting Format, Protection, I found
that the Text was checked.

When I removed this check, my code worked OK...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top