Visio Guy

Visio Discussions => Programming & Code => Topic started by: sruikar on January 16, 2020, 05:47:25 PM

Title: Couldn't able to read data from container text area
Post by: sruikar on January 16, 2020, 05:47:25 PM
Hi all ,

I'm trying to read data from visio container which is written in the text area through vba script and writing same in notepad,  but couldn't fetch data for any container.

I'm adding attachment of vsd file . Any help will be appreciated.


Tried Code sample :

For Each memberID In vsoContainerShape.ContainerProperties.GetMemberShapes(visContainerFlagsDefault)
       
            Set vsoShape = vsoPage.Shapes.ItemFromID(memberID)
            'shape_details = "BlOCK_START"
            intRows = vsoShape.RowCount(Visio.visSectionProp)
            Debug.Print vsoShape.Text
           
             
           
            'If intRows > 0 Then
             
            'Debug.Print vsoShape.Text
            'sample_one = shape_details + sample_one + vbCrLf + vsoShape.Text
            shape_details = "BlOCK_START" + vbCrLf + vsoShape.Text
            sample_one = sample_one + shape_details '+ sample_one + vbCrLf + vsoShape.Text
            sample_one = sample_one + vbCrLf + "BlOCK_END" + vbCrLf
            Set shape_details = Nothing
            Debug.Print sample_one
           
            'End If
             
        intRows = 0
        Next
        openContainer = sample_one & vbCrLf & "**END**"

Thanks in advance
Title: Re: Couldn't able to read data from container text area
Post by: Obsidian on January 17, 2020, 08:54:14 AM
Hello! If i correctly understand your question, for resolve your problem you need tio use recursive shape select:


Public Sub Main()
Dim shp As Visio.Shape
       
    'start "PrintShapeText" calls
    For Each shp In Application.ActivePage.Shapes
        PrintShapeText shp
    Next shp
   
End Sub

Private Sub PrintShapeText(ByRef shp As Visio.Shape)
Dim subShp As Visio.Shape
   
    Debug.Print shp.Name & ".text = " & shp.Text
   
    If shp.Shapes.Count > 0 Then
        'recurse "PrintShapeText"  call
        For Each subShp In shp.Shapes
            PrintShapeText subShp
        Next subShp
    End If
End Sub