Exporting length of connectors to Excel

M

Mac

Hello,
I have several layers packed with objects and connectors linking these
together. I need to extract the length ( was told that it's stored in the
LengthUI var) of each connector on a specific layer and save it to a list,
preferrably an Excel sheet. Is there any ( similar at least) sample code for
me to see how to achieve this? Or someone willing to take their time and
share their ideas? Thanks in advance!
Mac
 
J

John Goldsmith

Hello Mac,

Here's some code to produce a csv (saved in the same location and name) file
that you could open in Excel:

Sub Report1dLengths()
'Requires reference to
'Microsoft Scripting Runtime (see Tools/References
'in the VBE
Dim pag As Page
Dim shp As Shape
Dim sLayers As String
Dim fso As FileSystemObject
Dim ts As TextStream
Dim sFileName As String

sFileName = ThisDocument.Path & Replace(ThisDocument.Name, ".vsd", ".csv")
Set fso = New FileSystemObject
Set ts = fso.CreateTextFile(sFileName, True)
ts.WriteLine "Page Name,Shape ID,Assigned to layers:,Shape Length (inches)"

For Each pag In ThisDocument.Pages
For Each shp In pag.Shapes
If shp.OneD = True And shp.Type = visTypeShape Then
For i = 1 To shp.LayerCount
sLayers = sLayers & shp.Layer(i).Name & ";"
Next i
ts.WriteLine pag.Name & "," & shp.ID & "," & sLayers & "," &
shp.LengthIU
sLayers = ""
End If
Next shp
Next pag
ts.Close
End Sub

If this is functionality you need a lot then you might find it easier to
write some code to add a User cell to the connector Masters that could then
be reported by Visio's own reporting tools (see Data / Reports... menu).

Anyway, hopefully this will point you in the write direction.

Best regards

John


John Goldsmith
www.visualSignals.co.uk
 
M

Mac

John,

as I am not a VB developer (assembler, C & C++ are my best friends) I'll
have to take some time to study what's really happening there and run it
through my drawings, but at the first glance it seems you've put everything I
need to work with in there! Thank you sooo much! :)
Mac
 
M

Mac

John,

adding a User cell to the connector Masters, ...could you be more specific
about this? What will I achieve by this and ...I am sure you have a code
snippet for such action up your sleeve again...? :)

Mac
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top