Hide or show Tag from VBA

D

Diane

When I rightclick a shape I can hide or show it's Tag.

What are the commands to do that from VBA?
 
C

Chris Roth

Not exactly sure what you're talking about, but I'll take a guess.

The shape you are using has a custom right-click, or context menu that
allows you to hide and show some graphics.

Inside the ShapeSheet for this shape is an Actions section. There will be a
formula under the hide/show rows that looks something like one of these:

SetF( "User.TagVisible", Not(User.TagVisible) )
SetF( GetRef( User.TagVisible ), Not(User.TagVisible) )

What you are looking for is the target cell - whatever the name of the cell
that is the first argument in the SetF function. In my example,
"User.TagVisible" is the cell that you care about. Then the VBA code is
simple:

Dim shp as Visio.Shape
Set shp = Visio.ActiveWindow.Selection(1)
shp.Cells( "User.TagVisible" ).ResultIU = 1 ' 1 = true, 0 = false

--

Hope this helps,

Chris Roth
Visio MVP
visioguy @ extremely warm mail.com
 
D

Diane

I have the following VBA code in Visio - it loops through all shapes on a
page - and displays the name:

Public Sub ShapeNames_Example()
Dim i As Integer
Dim iShapeCount As Integer
Dim shpsObj As Visio.Shapes

Set shpsObj = ActiveDocument.Pages.Item(1).Shapes
iShapeCount = shpsObj.Count
If iShapeCount > 0 Then
For i = 1 To iShapeCount
MsgBox ("Name: " & shpsObj.Item(i).Name & " Type: " &
shpsObj.Item(i).Type)
Next i
End If
End Sub

I want to extend this code to do other things - one is to show the "tag" on
the shape if it is a certain type of shape - and not for the rest. So my
question is: How do I set the "show tag" on shpsObj.Item(i) (which is the
relevant shape)

I looked at the ShapeSheet -but that did not make things simpler...
 
C

Chris Roth

You can check for a number of things:

shp.Master.Name. Make sure Not( shp.Master is nothing ) = true.

If you have designed the shapes yourself, you can insert a user cell in teh
ShapeSheet. Something like User.Class, or User.MySpecialCell, then check for
shp.CellExists( "User.MySpecialCell", false)

I'm still not clear what you mean by "Tag". Hopefully I'm guessing
correctly.

Happy Holidays,

Chris.
 

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