Hi all,
I am brand new to Visio Macros, I have had some experience in Excel but I am struggling to get a start in Visio.
Basically, I am trying to create a macro that will number shapes automatically and I would be able to re-run it if I add/remove shapes.
Also I would like to append some text based on a set field E.G Procedure_#
So to start with I am trying to do something simple and count the number of shapes on screen
I am a bit confused I have looked up this reference here...however it seems to be counting documents?
https://msdn.microsoft.com/en-us/vba/visio-vba/articles/shapes-count-property-visio
Also I have found a snippet of code to try however I am unsuccesfull.
Sub Counter()
Dim shp As Visio.Shape
Dim i As Integer
For Each shp In ActivePage.Shapes
If shp.Master<>Nothing Then
i = i + 1
End If
ActivePage.Shapes("SheetED").Characters.Text = CStr(i)
End If
Next shp
Debug.Print i
End Sub
Does the built-in shape number not do what you want?
View -> Addons -> Visio Extras -> Number shapes
Thanks, I have looked into that, unfortunately no, as I want to append its text to show for exxample Procedure_1
Unless theres a way to specify where the numbering goes?
1)
Quote from: JeanK on November 09, 2017, 05:01:52 AM
... however I am unsuccesfull. ...
What is the problem with your code?
2)
You can number the shapes directly by assigning i to a "number" field (eg prop.number)
Sub Number()
Dim shp As Visio.Shape
Dim i As Integer
For Each shp In ActivePage.Shapes
If shp.Master<>Nothing Then
i = i + 1
if shp.cellexistsu("prop.number",false) then
shp.cells("prop.number").formulau = i
end if
End If
End If
Next shp
End Sub
and you can insert this field in the shape to be displayed. (https://support.office.com/en-us/article/Insert-a-text-field-into-a-shape-0225c22e-3e5e-4ea7-9ca0-1ec91386cb1e)
Quote from: JeanK on November 09, 2017, 08:47:09 PM
Thanks, I have looked into that, unfortunately no, as I want to append its text to show for exxample Procedure_1
Unless theres a way to specify where the numbering goes?
Yes, have as look on the Advanced tab of the Shape number dialog.
Excellent!!@!@
Yes the advanced shape parramaters help me achieved this, sorry I didn' look hard enough!
Also thanks for the code, I was interested in doing this programatically too!
Thanks all!
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: 55 (
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_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: 770KB.
Tokens:
post-login.
Cache hits: 6: 0.00141s for 22,291 bytes (
showget modSettings: 0.00047s - 19982 bytes, get known_languages: 0.00015s - 1277 bytes, get board_parents-0: 0.00044s - 2 bytes, get permissions:-1: 0.00009s - 50 bytes, get theme_settings-1: 0.00023s - 980 bytes, get menu_buttons--1-english: 0.00003s - 0 bytes)
Cache misses: 1: (
showget menu_buttons--1-english)
Queries used: 8.
[Show Queries]