oompa_l was wondering how to set the Height formula for a bunch of shapes over in this thread: http://visguy.com/vgforum/index.php?topic=47.0
I'll talk about two ways of going about this right now.
Are the shapes all instances of the same master?
If so, then do this:
1. File > Shapes > Show Document Stencil to see the local stencil, which contains masters used in the document
2. Double-click the master icon
3. Edit the formula
This will change the formula in all the instances in all of the pages in the document -- unless -- you've already overridden formulas in individual shapes.
Write a macro
Like Cyndi Lauper sang, Coders just want to have fun. We can always get more done, more quickly (and cause more trouble) with VBA. So let's have at it:
'// Get a bunch of selected shapes
Dim sel as Visio.Selection
Set sel = Visio.ActiveWindow.Selection
'// 'Do' each shape in the selection:
Dim shp as Visio.Shape
For Each shp in sel
'// Note: here are several examples that you can
'// comment-out and uncomment
'// Set the value in inches:
shp.Cells("Width").ResultIU = 2.0
'//...or set the value in centimeters:
'shp.Cells("Width").Result(Visio.visUnitCodes.visCentimeters) = 50.8
'//...or set the formula
'shp.Cells("Width").Formula = "GUARD(Prop.Row_1)"
'//...or override a cell that already has a GUARDed formula:
'shp.Cells("Width").FormulaForce = "GUARD(Prop.Row_1)"
'// You can get at cells with indices as well:
'shp.CellsSRC(Visio.VisSectionIndices.visSectionObject, _
' Visio.VisRowIndices.visRowXFormOut, _
' Visio.VisCellIndices.visXFormWidth).Result = 3.0
'// Put the cursor in a ShapeSheet cell, then hit F1 to get the
'// Section, Row, Column indices for a cell.
Next shp
where can i go for explanation on implementing macros?
I prefer option 1, but I am still having trouble understanding masters...I would assume tha a change in a master would affect all instances but I have found this not to be the case. Also, when I tried to make a shape from scratch and place in the master a formula that included a formula, in this case "=Prop._VisDM_length_in/50" I was told there was an error in the formula. My guess s that it's because there is no shapesheet data and so it doesnt know what I am referring to. It seems to be a chicken-egg scenario. My is Visio finicky, or what!
i tried to find my way intuitively to making that macro but I got an error:
"Compiler Error
Invalid Outside Procedure"
The whole bunch of code needs to be wrapped in a sub, ie:
Sub DoStuff
...
...
End Sub
woh! it worked...
and...when you have a moment, I am still unsure how to build the formula into the master shape - I was getting an error before. see above.
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: 52 (
showintegrate_autoload, cache_get_data, integrate_pre_load, integrate_load_session, integrate_verify_user, cache_get_data, integrate_user_info, integrate_load_board, cache_get_data, integrate_board_info, cache_get_data, integrate_allowed_to_general, integrate_pre_load_theme, cache_get_data, integrate_allowed_to_general, integrate_simple_actions, integrate_allowed_to_general, integrate_load_theme, integrate_pre_log_stats, integrate_actions, integrate_pre_parsebbc, integrate_bbc_codes, integrate_bbc_print, integrate_post_parsebbc, integrate_pre_parsebbc, integrate_bbc_print, integrate_post_parsebbc, integrate_pre_parsebbc, integrate_bbc_print, integrate_post_parsebbc, integrate_pre_parsebbc, integrate_bbc_print, integrate_post_parsebbc, integrate_pre_parsebbc, integrate_bbc_print, integrate_post_parsebbc, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general, integrate_menu_buttons, integrate_current_action, integrate_theme_context, integrate_allowed_to_general, integrate_allowed_to_general, integrate_allowed_to_general)
Files included: 25 - 922KB. (
show/home/iw0lkfe3x6cq/public_html/vgforum/index.php, /home/iw0lkfe3x6cq/public_html/vgforum/Settings.php, /home/iw0lkfe3x6cq/public_html/vgforum/cache/db_last_error.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/QueryString.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Subs.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Subs-Auth.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Errors.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Load.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Security.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Subs-Compat.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Subs-Db-mysql.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Cache/CacheApi.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Cache/CacheApiInterface.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Cache/APIs/FileBased.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Subs-Charset.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Unicode/Metadata.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Unicode/QuickCheck.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Session.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Logging.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Class-BrowserDetect.php, (Current Theme)/languages/index.english.php, (Current Theme)/languages/Modifications.english.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Printpage.php, (Current Theme)/Printpage.template.php, /home/iw0lkfe3x6cq/public_html/vgforum/Sources/Unicode/CaseUpper.php)
Memory used: 774KB.
Tokens:
post-login.
Cache hits: 6: 0.00135s for 22,291 bytes (
showget modSettings: 0.00051s - 19982 bytes, get known_languages: 0.00029s - 1277 bytes, get board_parents-0: 0.00022s - 2 bytes, get permissions:-1: 0.00013s - 50 bytes, get theme_settings-1: 0.00017s - 980 bytes, get menu_buttons--1-english: 0.00003s - 0 bytes)
Cache misses: 1: (
showget menu_buttons--1-english)
Queries used: 8.
[Show Queries]