Visio analysis by dumping all objects into CSV for Excel analysis
Besides using LOCS as a rough estimation, I also use Visio flowchart as a rough estimation for software development projects.
The below VBS file is to quickly dump all the object into a CSV file. Then I open it in Excel, use PivotTable to count the number of pages and shapes inside each page.
This way, I can quickly figure out the complexity of the Visio for a ballpark of the complexity for effort estimation in software development projects.
The below VBS file is to quickly dump all the object into a CSV file. Then I open it in Excel, use PivotTable to count the number of pages and shapes inside each page.
This way, I can quickly figure out the complexity of the Visio for a ballpark of the complexity for effort estimation in software development projects.
' Instruction:
' To run this, run at command prompt:
cscript Visio_shapes_analysis.vbs
' References:
'
https://msdn.microsoft.com/en-us/library/cc160740.aspx -- Visio Object Model
'
https://support.microsoft.com/en-us/kb/309603
docPath
= "C:\data\myVisio.vsd" ' My Visio File
' Normally, I will open the Visio first. The below snippet get the opened Visio program.
Set AppVisio = GetObject(, "visio.application")
' If Visio is not opened, then it will open it for you.
If AppVisio Is Nothing Then
Set AppVisio = CreateObject("visio.application")
AppVisio.Visible = True
AppVisio.documents.Open docPath
End If
' For writing the result into a CSV (tab separated)
Set objFSO=CreateObject("Scripting.FileSystemObject")
' How to write file
outFile="D:\data\Visio_Analysis.csv"
Set objFile = objFSO.CreateTextFile(outFile,True,True) ' 2nd True=Overwrite
' 3rd True=Unicode
Set MyDoc = AppVisio.ActiveDocument
Set MyDocPages = MyDoc.Pages
nPageCount = MyDoc.Pages.Count
' To echo the filename at Command Prompt
WScript.StdOut.WriteLine "Filename: " & MyDoc.Name
' File Header
objFile.Write "PageNo" & vbTab &
"PageName" & vbTab &
"ObjName" & vbTab &
"ObjID" & vbCrLF
For intPageCount = 1 To nPageCount
' WScript.StdOut.WriteLine "Page: " &
MyDocPages.Item(intPageCount).Name
Set vsoShapes = MyDocPages.Item(intPageCount).Shapes
intShapeCount = vsoShapes.Count
If intShapeCount >
0 Then
For intCounter = 1 To intShapeCount
shapeName = vsoShapes.Item(intCounter).Name
shapeName = Replace(StrReverse(shapeName),".", vbTab, 1, 1)
shapeName = StrReverse(shapeName)
objFile.Write intPageCount _
& vbTab &
MyDocPages.Item(intPageCount).Name _
& vbTab &
shapeName _
& vbCrLF
Next
Else
objFile.Write "
No Shapes On Page" & vbCrLF
End If
Next
objFile.Close
Comments