need help with shape calling a macro

Started by jwspiegel, November 15, 2016, 04:39:07 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

jwspiegel

I am using a "CustomTag" to store information about the part being dropped on the page. The tag is part of the larger stencil and i am needing to fill in two property fields when the part is first dropped on the page. My issue i'm having is my current code will change a single instance of Custom Tag if multiple are on the page but not the one that is newly dropped.I am needing only the tag that was dropped to be changed.  I am calling the macro from the events shape sheet. My test code is below. Any Help would be appreciated.

Public Sub Set_Tag()

Dim shpObj As Visio.Shape
Dim cellobj As Visio.Cell
Dim Rev_Number As Integer
Dim Proj_Number As Double
Dim TheShapes As Shapes

Rev_Number = 1
Proj_Number = 16212.01
' Obtain the list of shapes
   Set TheShapes = ActivePage.Shapes
   
   ' Holds individual shape data.
   Dim ThisShape As Shape
   Dim ShapeNames As String
   Dim showForm As String
   
   ' Obtain each shape and add it to the list.
   For Each ThisShape In TheShapes
     
       ShapeNames = ShapeNames + ThisShape.Name + vbCrLf
       If ThisShape.Name = "CustomTag" Then
         MsgBox "here"
         
          ThisShape.CellsU("Prop.Revision") = Rev_Number
          ThisShape.CellsU("Prop.Project") = Proj_Number
       
           
       End If
   
   Next
End Sub

wapperdude

The newly dropped shape ought to be selected, so  just use the selected shape rather than looping thru the shapes collection.

Wapperdude
Visio 2019 Pro

jwspiegel

The issue is the tags are shapes grouped within the larger stencil... so when the stencil is dropped there are a number of shapes selected.

Browser ID: smf (is_webkit)
Templates: 4: index (default), Display (default), GenericControls (default), GenericControls (default).
Sub templates: 6: init, html_above, body_above, main, body_below, html_below.
Language files: 4: index+Modifications.english (default), Post.english (default), Editor.english (default), Drafts.english (default).
Style sheets: 4: index.css, attachments.css, jquery.sceditor.css, responsive.css.
Hooks called: 172 (show)
Files included: 34 - 1321KB. (show)
Memory used: 1062KB.
Tokens: post-login.
Cache hits: 13: 0.00149s for 26,582 bytes (show)
Cache misses: 2: (show)
Queries used: 16.

[Show Queries]