Creating and linking shapes

D

dirk.devos

I would like to find out what is the most effcient way to find and
select a shape given the following.

I have 2 data sources. The one contains a list of tasks and for each
task I want to place a shape on a page. For each task I have my own
task ID as well as a task name. I put this task ID in the text property
of the shape. The other data source contains a list of task
relationships. Each line in this file has a "from" task ID and a "to"
task ID.

I first read the first data source and drop all the tasks on the page.
I then read the second source and search thru all the dropped tasks
until I find both the "from" and the "to" task IDs that was stored in
the text property of the shape.

This works well if I only have a couple of tasks but when I get into
the hundreds of tasks and relationships things slow down so much that
it becomes a pain to do.

Is there any other way to assign something to the shape after dropping
it on the page that will allow me to select the shape quicker. I tried
the ID property of the shape but it is read only.
 
A

Al Edlund

when you drop the shape on the page change the name to your taskid (I
usually do the name and nameu) then you can just assign your endpoints
without having to search for the shape.
al
 
D

dirk.devos

Thanks for the info. I was able to set the name but I have no idea how
to assign the endpoints. I tried selecting the shape based on the name
property but was not successfull. Please show me how to link the two
shapes after I have dropped them.
 
A

Al Edlund

the quick way to see it is to use the visio macro recorder function. drop
two shapes on the page and then connect them. the macro should give you a
template to start from. There are also examples in the visio sdk (although
shown in visual basic, they are fairly close to vba).
al
 
D

dirk.devos

I tried the macro recorder but that did not help any. I think I will
just leave the code as is. Maybe the next version of Visio will do it.
 
D

dirk.devos

I found a solution.

Public Sub find_shape()

Dim str_shape_name As String
Dim shp_obj As Visio.Shape

ActiveWindow.DeselectAll
str_shape_name = "TASKID-05"
Set shp_obj = Application.ActivePage.Shapes.ItemU(str_shape_name)

ActiveWindow.Select shp_obj, visSelect

End Sub
 

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