I found and corrected this code to connect shapes from excel data file. I hope it will be useful for others.
Public Sub DrawSystem()
Dim strConnection As String
Dim strCommand As String
Dim strOfficePath As String
Dim vsoDataRecordset As Visio.DataRecordset
strConnection = "Provider=Microsoft.ACE.OLEDB.12.0;" _
& "User ID=Admin;" _
& "Data Source=" + "C:\example.xls;" _
& "Mode=Read;" _
& "Extended Properties=""HDR=YES;IMEX=1;MaxScanRows=0;Excel 12.0;"";" _
& "Jet OLEDB:Engine Type=34;"
strCommand = "SELECT * FROM [Sheet1$]"
Set vsoDataRecordset = ActiveDocument.DataRecordsets.Add(strConnection, strCommand, 0, "Objects")
Dim stnObj As Visio.Document
Dim mastObj As Visio.Master
Dim pagsObj As Visio.Pages
Dim pagObj, activePageObj As Visio.Page
Dim shpObj As Visio.Shape
Dim shpFrom As Visio.Shape
Dim shpTo As Visio.Shape
Set stnObj = Documents.OpenEx("Basic Shapes.vss", visOpenDocked)
Set pagObj = ThisDocument.Pages.Add()
Dim lngRowIDs() As Long
Dim lngRow As Long
Dim lngColumn As Long
Dim varRowData As Variant
Debug.Print "PROCESSING ENTITY RECORDS"
lngRowIDs = vsoDataRecordset.GetDataRowIDs("")
Set mastObj = stnObj.Masters("Rectangle")
For lngRow = LBound(lngRowIDs) To UBound(lngRowIDs)
varRowData = vsoDataRecordset.GetRowData(lngRow)
If varRowData(2) = "ENTITY" Then
Set shpObj = pagObj.Drop(mastObj, lngRow / 2, lngRow / 2)
shpObj.Name = varRowData(3)
shpObj.Text = varRowData(7)
shpObj.Data1 = varRowData(3)
shpObj.Data2 = varRowData(7)
shpObj.Data3 = varRowData(8)
shpObj.Cells("Width") = 0.75
shpObj.Cells("Height") = 0.5
End If
Next lngRow
lngRowIDs = vsoDataRecordset.GetDataRowIDs("")
Set mastObj = stnObj.Masters("Dynamic connector")
For lngRow = LBound(lngRowIDs) To UBound(lngRowIDs)
varRowData = vsoDataRecordset.GetRowData(lngRow)
Debug.Print ("!ddd!!" & varRowData(2))
If varRowData(2) = "LINK" Then
Dim fromName As String
fromName = varRowData(4)
Dim toName As String
toName = varRowData(5)
Dim conName As String
conName = varRowData(6)
Set shpCon = pagObj.Drop(mastObj, 2 + lngRow * 3, 0 + lngRow * 3)
varRowData = vsoDataRecordset.GetRowData(lngRow)
shpCon.Name = conName
shpCon.Text = varRowData(7)
Set shpFrom = ActivePage.Shapes(fromName)
Set shpTo = ActivePage.Shapes(toName)
shpFrom.AutoConnect shpTo, visAutoConnectDirNone, shpCon
End If
Next lngRow
End Sub
1,,ENTITY,A,,,1,1: A,ONE
2,,ENTITY,B,,,2,2: B,TWO
3,,ENTITY,C,,,3,3: C,THREE
13,1,LINK,LINK1,A,B,13.1,13.1: LINK1,LINK1
13,2,LINK,LINK2,A,C,13.2,13.2: LINK2,LINK2
13,2,LINK,LINK2,C,B,13.2,13.2: LINK2,LINK2