Author Topic: Validate if ActiveWindow.Selected Shape is In A Container  (Read 84 times)

0 Members and 1 Guest are viewing this topic.

soulshined

  • Newbie
  • *
  • Posts: 9
Validate if ActiveWindow.Selected Shape is In A Container
« on: September 12, 2017, 06: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

Code: [Select]
   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?

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2896
  • Ideas Visio-lized into solutions

soulshined

  • Newbie
  • *
  • Posts: 9
Re: Validate if ActiveWindow.Selected Shape is In A Container
« Reply #2 on: September 14, 2017, 01:40:45 PM »
See this:  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!

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2896
  • Ideas Visio-lized into solutions
Re: Validate if ActiveWindow.Selected Shape is In A Container
« Reply #3 on: September 14, 2017, 01:56:20 PM »
Cool!  I have V2007 so couldn't directly answer your question.  Glad it was resolved.