Visio Guy

Visio Discussions => Programming & Code => Topic started by: soulshined on September 12, 2017, 11:30:43 PM

Title: Validate if ActiveWindow.Selected Shape is In A Container
Post by: soulshined on September 12, 2017, 11:30:43 PM
I'm simply trying to determine if the currently selected object (shape) is INSIDE a container.

After I verify shape is inside container I would like to set a variable to the container object to use later


   Dim activeShp As Shape, containerShp As Shape

   Set activeShp = Application.ActiveWindow.Selection(1)
   Debug.Print activeShp.ContainingShape.ContainerProperties.ContainerType 
   


That isn't working. ContainerType is supposed to return Nothing if it is not a container, 0 & 1 otherwise. I've been trying everything on the Shape MSDN with no luck. There has to be a fool proof way to test if a selected item is in a container right?
Title: Re: Validate if ActiveWindow.Selected Shape is In A Container
Post by: wapperdude on September 14, 2017, 02:51:24 PM
See this:  https://msdn.microsoft.com/VBA/Visio-VBA/articles/shape-memberofcontainers-property-visio (https://msdn.microsoft.com/VBA/Visio-VBA/articles/shape-memberofcontainers-property-visio).

Wapperdude
Title: Re: Validate if ActiveWindow.Selected Shape is In A Container
Post by: soulshined on September 14, 2017, 06:40:45 PM
Quote from: wapperdude on September 14, 2017, 02:51:24 PM
See this:  https://msdn.microsoft.com/VBA/Visio-VBA/articles/shape-memberofcontainers-property-visio (https://msdn.microsoft.com/VBA/Visio-VBA/articles/shape-memberofcontainers-property-visio).

Wapperdude

Oops. Well thank you for taking the time to lead me here. This answers my question and got the results I needed!
Title: Re: Validate if ActiveWindow.Selected Shape is In A Container
Post by: wapperdude on September 14, 2017, 06:56:20 PM
Cool!  I have V2007 so couldn't directly answer your question.  Glad it was resolved.