Option Explicit
Public Sub LocationTable()
'This routine will create a text file of the location and size of all 2-d shapes
' on the current page
Dim shpObj As Visio.Shape, celObj As Visio.Cell
Dim ShpNo As Integer, Tabchr As String, localCent As Double
Dim LocationX As String, LocationY As String
Dim ShapeWidth As String, ShapeHeight As String
'Open or create text file to write data
Open "C:\LocationTable.txt" For Output Shared As #1
Tabchr = Chr(9) 'Tab
'Loop Shapes collection
For ShpNo = 1 To Visio.ActivePage.Shapes.Count
Set shpObj = Visio.ActivePage.Shapes(ShpNo)
If Not shpObj.OneD Then ' Only list the 2-D shapes
'Get location Shape
Set celObj = shpObj.Cells("pinx")
localCent = celObj.Result("inches")
LocationX = Format(localCent, "000.0000")
Set celObj = shpObj.Cells("piny")
localCent = celObj.Result("inches")
LocationY = Format(localCent, "000.0000")
'Get Size Shape
Set celObj = shpObj.Cells("width")
localCent = celObj.Result("inches")
ShapeWidth = Format(localCent, "000.0000")
Set celObj = shpObj.Cells("height")
localCent = celObj.Result("inches")
ShapeHeight = Format(localCent, "000.0000")
'Write values to Text file starting Name of Shape
Print #1, shpObj.Name; shpObj.Text; Tabchr; _
Tabchr; LocationX; Tabchr; LocationY; _
Tabchr; ShapeWidth; Tabchr; ShapeHeight
End If
Next ShpNo
'Close Textfile
Close #1
'Clean Up
Set celObj = Nothing
Set shpObj = Nothing
End Sub
|