0
votes

I have the following code:

var activeWindow = Application.ActiveWindow;

        foreach (Visio.Shape shapeItem in activeWindow.Selection)
        {
            System.Windows.Forms.MessageBox.Show(shapeItem.Name);
            if(shapeItem.SectionExists(visSectionConnectionPts, false) = false)
            {

            }
        }

I am iterating through a collection of shapes and outputting the name of each shape. To extend this - I am trying to see if (for each selected shape) the section visSectionConnectionPts exists - as I am trying to add connection points to the currently selected shape. I get two errors:

  1. Non-invocable member 'IVShape.SectionExists[Short,Short]' cannot be used like a method.
  2. The name 'visSectionConnectionPts' does not exist in the current context.

How can I proceed with the above?

1
according to this sectionexists returns an integer and not a boolean msdn.microsoft.com/en-us/library/office/ff766437.aspx - Amen Jlili

1 Answers

0
votes

As @Jelly points out the method returns a short (in the case of c#) and both arguments are shorts too. So you need to use the qualified enum and cast it to a short:

if (shp.SectionExists[(short)Visio.VisSectionIndices.visSectionConnectionPts, 0] == 0)
{
    shp.AddSection((short)Visio.VisSectionIndices.visSectionConnectionPts);
}