Visio Guy

Visio Discussions => Programming & Code => Topic started by: nitra_ma on October 31, 2017, 06:10:28 PM

Title: Create a Search macro that liste all the shape found
Post by: nitra_ma on October 31, 2017, 06:10:28 PM
Hi,

I want to built a "find all" macro that will find all the shape with a specific shape data and list all these shape in a pop-up window (something like a list in a msgbox) and let the user to choose wich one he want to see.   Something like the "findAll" in excel

Is there something already done into visio...

For the moment, I find a way to loop through all pages and all shapes to find the matching shape, and now I will need to built a custom form and redo what the "findall" in excel do... (big job)

Any suggestions
Title: Re: Create a Search macro that liste all the shape found
Post by: Yacine on October 31, 2017, 09:48:54 PM
The enclosed file should get you started. But there's still a lot of work.
Consider units, sub-shapes, other pages, multiple conditions, etc.
Title: Re: Create a Search macro that liste all the shape found
Post by: nitra_ma on November 02, 2017, 12:45:44 AM
Wow, perfect. 

The ID of a item is unique on one page... but if I worked on multiple page, I will need to search throught all page (ok, no problem) and memorize the page and the ID of the found Item... what the best way to do that : create a structure an memorize that into the struct or just add it in the listresults in two column

Your code work perfectly... in fact, you already do 80% of what I need... (THANKS A LOT)

The last thing is I want to be able to clik on a shape and execute the search by using the filed PROP.A of the shape that I was click on... so, fill some parameters of the search windows by using the info of the clicked shape, or, pass some parameter to a function

Can you give my an idea


Title: Re: Create a Search macro that liste all the shape found
Post by: Yacine on November 02, 2017, 09:52:57 AM
1) searching in multiple pages:
There are unique IDs that you could create (built in function --> google). But I haven't tried to address shapes independently from their pages. So I'd prefer to use a structure as suggest, but a two column list is already such a structure. So use this simpler solution.

2) pre-fill the dialog:
get the selected shape (set shp = activewindow.selection(1) )
iterate through its prop section (use the macro recorder to get the commands)
fill a fields list with the results.

Top notch would be to display ALL the fields of the shapesheet.

Cheers,
Y.
Browser ID: smf (is_webkit)
Templates: 1: Printpage (default).
Sub templates: 4: init, print_above, main, print_below.
Language files: 1: index+Modifications.english (default).
Style sheets: 0: .
Hooks called: 54 (show)
Files included: 25 - 922KB. (show)
Memory used: 747KB.
Tokens: post-login.
Cache hits: 8: 0.00180s for 22,301 bytes (show)
Cache misses: 2: (show)
Queries used: 11.

[Show Queries]