I use Document_ShapeAdded even to launch some script - i want it to be launched if i draw a line.
i use the following code
Quote'Debug.Print vsoShape.GeometryCount
geom_c = vsoShape.GeometryCount
geom1_r = vsoShape.RowCount(visSectionFirstComponent)
If Not ActivePage.name = "исх. схема" Then Exit Sub
If geom_c = 1 And geom1_r = 3 Then
thus code is exacuted for definite page and if shape is a line.
THe problem is if i copy-paste part of the drawing (manually or via macros) macro is exacuted a lot of times - i don't need it.
how can i avoid this ?
maybe it's possible to enable/disable Document_ShapeAdded macro ? or is it possible to get if shape is copy/pasted ?
Shapeadded can be fired by a lot of different scenarios, so you might want to check to see what 'scope' it is embedded in. The following might give you some ideas on what can be looked for
al
'********* visio snippet vb.net vis0050vb ******************
Private WithEvents pageShapeIsOn As Microsoft.Office.Interop.Visio.Page
Private eventApplication As Microsoft.Office.Interop.Visio.Application
Private Sub shapeAddedEventHandler _
(ByVal addedShape As Microsoft.Office.Interop.Visio.Shape) _
Handles pageShapeIsOn.ShapeAdded
Try
' Passing visCmdObjectGroup as a parameter to the IsInScope
If eventApplication.IsInScope(VisUICmds.visCmdObjectGroup) Then
'Debug.Print("Shape added using grouping action. " _
' & "Master name of the shape - " _
' & strMasterName)
' is in scope with apply data graphic
ElseIf eventApplication.IsInScope(VisUICmds.visCmdApplyDataGraphic) Then
'Debug.Print("Shape Added using Apply Data Graphic")
' IsInScope with visCmdUFEditPaste parameter returns
ElseIf eventApplication.IsInScope(VisUICmds.visCmdUFEditPaste) Then
'Debug.Print("Shape added using EditPaste action. " _
' & "Master Name of the Shape - """ _
' & strMasterName)
' IsInScope with visCmdEditPasteSpecial parameter
ElseIf eventApplication.IsInScope(VisUICmds.visCmdEditPasteSpecial) Then
'Debug.Print("Shape added using EditPasteSpecial " _
' & "action. Master name of the shape - " _
' & strMasterName)
ElseIf eventApplication.IsUndoingOrRedoing() = True Then
'Debug.WriteLine("Shape is added as a result of Undo/Redo.")
' If the shape is added using a normal user draw action, show
' the name of the shape being added.
Else
System.Diagnostics.Debug.WriteLine( _
"A shape has been added." _
& vbCrLf & "The universal name of the shape is " _
& addedShape.NameU)
End If
Catch err As System.Runtime.InteropServices.COMException
' add com exception handler here
End Try
End Sub
can't get your exmaple to work. can you post vsd example ?
actually the good news is the latest sdk (v2010) has replaced the vb6 code samples with vba samples and the above code has a version in it for shape added events.
al
can you post it in here as a vsd example ?
hth,
al
v2010
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: 56 (
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, cache_get_data, 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 - 925KB. (
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: 775KB.
Tokens:
post-login.
Cache hits: 7: 0.00146s for 22,301 bytes (
showget modSettings: 0.00049s - 19982 bytes, get known_languages: 0.00026s - 1277 bytes, get board_parents-0: 0.00022s - 2 bytes, get permissions:-1: 0.00008s - 50 bytes, get theme_settings-1: 0.00030s - 980 bytes, get log_online-update: 0.00009s - 10 bytes, get menu_buttons--1-english: 0.00002s - 0 bytes)
Cache misses: 1: (
showget menu_buttons--1-english)
Queries used: 9.
[Show Queries]