Visio Guy

Visio Discussions => Programming & Code => Topic started by: longo93 on June 21, 2016, 08:36:55 AM

Title: Exclude Connectors
Post by: longo93 on June 21, 2016, 08:36:55 AM
Hey there,

i have written a vba code to export shape datas from visio to an excel file. its working pretty well. now i want to exclude all connectors i have used in my visio flow chart. my idea was something like ...

dim connector as "connectors"
....

If connector = "connectors"
         " do nothing with my excel file"

do u have any idea how can i select just the connector ?

Title: Re: Exclude Connectors
Post by: Surrogate on June 21, 2016, 09:19:58 AM
what are you mean as connector ?
Title: Re: Exclude Connectors
Post by: longo93 on June 21, 2016, 09:29:56 AM
I mean the lines between the shapes, my code recognizes that connector lines as a shape without data and produce a blank line in my excel file
Title: Re: Exclude Connectors
Post by: Surrogate on June 21, 2016, 09:32:15 AM
you mean dynamic connectors ?
Title: Re: Exclude Connectors
Post by: longo93 on June 21, 2016, 09:38:37 AM
yes dynamic connectors, sorry ^^
Title: Re: Exclude Connectors
Post by: metuemre on June 21, 2016, 09:45:02 AM
You need to check if the shape is 1D or 2D. Please see the sample code below

Private Sub Trial()
    For Each shp In ActivePage.Shapes
        If shp.OneD Then
        GoTo NextShp
        Else
        'Do your stuff like export to excel, etc.
        End If
NextShp:
    Next shp
End Sub
Title: Re: Exclude Connectors
Post by: Surrogate on June 21, 2016, 09:48:27 AM
try also
Dim sh As Shape
Set sh = ActiveWindow.Selection.PrimaryItem
If sh.Master = "Dynamic connector" Then ' exclude that shape
Title: Re: Exclude Connectors
Post by: longo93 on June 21, 2016, 10:00:23 AM
Thanks for your replies. Well i tried

For Each shp In ActivePage.Shapes
    If shp.OneD Then
        GoTo Nextshp
    Else
    i = i + 1

    blatt.Cells(i, 1).Value = shp.Cells("prop.ShapeNumber").Formula
    blatt.Cells(i, 2).Value = shp.Cells("prop.NameDE").ResultStr("")
     If shp.CellExists("prop.Typ", True) Then
        blatt.Cells(i, 3).Value = shp.Cells("prop.Typ").ResultStr("")
    Else
        blatt.Cells(i, 3).Value = ""
    End If
    End If


But this is not working cause of that "GoTo Nextshp"
Title: Re: Exclude Connectors
Post by: longo93 on June 21, 2016, 10:14:20 AM
Got it, thanks guys :)