使用 vb.net 获取 visio 形状的 X-Y 坐标

Getting X-Y coordinates for visio shapes using vb.net

我最近开始使用 vb.net 进行编程。 我正在尝试将 visio 中所有形状的 X-Y 坐标放入 csv 文件中。 我找到了 Russell Christopher 的 VBA 代码,其中的代码完全符合我的需要,但它在 VBA 中。我尝试重写 VB.net 中的代码,但由于我是新手,所以我不知道所有语法。这里的任何人都可以帮助我吗? 这是我需要转换的代码。

Public Sub WriteTableauPointsFile()
Dim oShape As Visio.Shape
Dim oPath As Visio.Path
Dim oPoints() As Double

'Set the output file to be the same as the source file, but .CSV
oFileName = Left(ActiveDocument.FullName, Len(ActiveDocument.FullName) - 3) & "csv"

'Set the separator character
oSeparator = "|"

'If file already exists, delete it
If Dir(oFileName) <> "" Then
    Kill oFileName
End If

'Open the output file and write the header line
oFile = FreeFile
Open oFileName For Append As #oFile
Print #oFile, "ShapeNo" & oSeparator & "ShapeName" & oSeparator & "PathNo" & oSeparator & "PointNo" & oSeparator & "X" & oSeparator & "Y"

'Get all the shapes on the page
ActiveWindow.SelectAll
Set oShapes = ActiveWindow.Selection


'Cycle through the shapes
For Each oShape In oShapes

    'Shapes can have multiple paths
    For j = 1 To oShape.Paths.Count
        Set oPath = oShape.Paths(j)

        'Enumerate the points in each path with 0.5 sensitivity for curves
        oPath.Points 0.5, oPoints
        i = 0
        Do While i < UBound(oPoints)
            x = Int(oPoints(i))
            y = Int(oPoints(i + 1))
            i = i + 2

            'Write the record for each point
            Print #oFile, oShape.Index; oSeparator; oShape.Text; oSeparator; j; oSeparator; i; oSeparator; x; oSeparator; y
        Loop
    Next j
Next

'Close the file and exit
Close #oFile

结束子

根据反复试验,我了解到 vb.net 中没有 "open" 这样的东西。我能够成功转换,直到 "open" 语句开始。

任何帮助将不胜感激。

谢谢, - 三木

我自己想出了答案。我想我会 post 把它放在这里,这样它可能会对以后寻找类似东西的人有所帮助。

Dim oPoints() as Double
oPath.Points(0.5, oPoints)
    i = 0
    Do While i < UBound(oPoints)
        x = Int(oPoints(i))
        y = Int(oPoints(i + 1))
        i = i + 2

代码的其余部分保持不变。