Change Text Value of all InformationFlow Shapes

Started by amax, January 18, 2016, 10:34:52 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

amax

Hey guys,

I'm new to this Visio topic, also my VBA skills are not A+ level. However, what I want to do is to change in a information flow shape the "Text Field"-Value of all Information Flow and Information Flow Bidirectional and Information Flow without direction.
To change this value in a single information flow it is like this:
Application.ActiveWindow.Shape.CellsSRC(visSectionTextField, 0, visFieldCell).FormulaU = "Prop._VisDM_Prop_InformationObjects"

But how I can get only, but all three Information Flow types in a Shape? Ok, I know with a loop, but how to catch not an Application?

Best regards
Amax

JohnGoldsmith

Hello Amax,


Which stencil and template is this from?  Also, are you trying to change on document or multiple ones?


Best regards


John
John Goldsmith - Visio MVP
http://visualsignals.typepad.co.uk/

amax

Hi John,

the used stecils are: InformationFlow, InformationFlowBidirectional, InformationflowNoDirection, Application-cp-s-Bo, Application-cp-s-Small, Application-cp-m-Bo, Application-cp-m-Small.
In the properties is the template information empty. As far as I know, this sheet is generated by a tool for drawing information flow diagrams.

I try to change one document, but use a external excel file to link the relevant information I want to change with the current one stored in the visio file.

JohnGoldsmith

Hi,

I think you're describing Master names rather than a stencil, which is the document that contains a set of masters?  I'm not familiar with the shapes you're describing, but is sounds like editting the document master shapes manually might be a better choice.  Do you have a sample document that you could post so we know what we're dealing with?

Best regards

John
John Goldsmith - Visio MVP
http://visualsignals.typepad.co.uk/

amax

Hey John,

I'm sorry that I can't be specific enough. Attached the file.

regards

JohnGoldsmith

#5
Hi,

Thanks - that's helpful. 

So as I understand it you want to edit the text fields of three of the Information type connector shapes - is that right? 

I see that a number of the shapes have local formulas (ie they do not inherit this information from their respective masters) and I think my approach would be to reset inheritance so that you can then edit the master manually in one place, and have the changes reflected across all of the instance shapes.

Anyway, it's up to you obviously, so I've included both options in the code below:

Public Sub ResetPageInfoConns()
    Dim newFormula As String
   
    'uncomment this line to reset the field cell's inheritance to point at the master
    'newFormula = "="
                       
    'or uncomment this line to set the instance (if you must!):
    'newFormula = "Prop._VisDM_Prop_InformationObjects"
   
    Dim masterNames As Variant
    masterNames = Split("InformationFlow;InformationFlowBidirectional;InformationFlowNoDirection", ";", newFormula)
    Call ResetFields(ActivePage, masterNames, newFormula)
End Sub

Private Sub ResetFields(ByRef targetPage As Visio.Page, masterNames As Variant, newFormula As String)
Dim shp As Visio.Shape
If Not targetPage Is Nothing Then
    For Each shp In targetPage.Shapes
        If Not shp.Master Is Nothing Then
            Dim i As Long
            For i = 0 To UBound(masterNames)
                If shp.Master.Name = masterNames(i) Then
                    If shp.CellsSRCExists(visSectionTextField, 0, visFieldCell, VisExistsFlags.visExistsLocally) Then
                        Debug.Print shp.Master.Name, shp.NameID, "Found shape with field"
                       
                        'uncomment to set the cell
                        'shp.CellsSRC(visSectionTextField, 0, visFieldCell).FormulaU = newFormula
                    Else
                        Debug.Print shp.Master.Name, shp.NameID, "Found shape with no field"
                    End If
                End If
            Next i
        End If
    Next
End If
End Sub


Let me know how you get on.

Best regards

John
John Goldsmith - Visio MVP
http://visualsignals.typepad.co.uk/

amax


JohnGoldsmith

Great.  Glad it worked for you.

Best regards

John
John Goldsmith - Visio MVP
http://visualsignals.typepad.co.uk/

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: 252 (show)
Files included: 34 - 1321KB. (show)
Memory used: 1111KB.
Tokens: post-login.
Cache hits: 13: 0.00202s for 26,582 bytes (show)
Cache misses: 2: (show)
Queries used: 14.

[Show Queries]