Published in: Visual Basic
Attribute VB_Name = "adjazenzMatrixToGraphviz" Sub adjazenzMatrixToGraphviz() i = 0 Dim z As Range Dim graph As String s = "digraph G{" nodeNameRow = Selection.Row nodeNameCol = Selection.Column For Each zelle In Selection 'falls nicht in der bezeichnungs spalte oder zeile If ((Not zelle.Row = nodeNameRow) And (Not zelle.Column = nodeNameCol)) Then If (Not zelle.Value = "") Then s = s & """" & Cells(zelle.Row, nodeNameCol) & """ -> """ & Cells(nodeNameRow, zelle.Column) & """ [label=""" & zelle.Value & """];" & vbCrLf End If End If Next s = s & "}" writeLine (s) WriteToATextFile (s) End Sub Sub writeLine(s As String) Debug.Print s End Sub Sub WriteToATextFile(s As String) MyFile = ActiveWorkbook.Path & "\graph.dot" 'set and open file for output fnum = FreeFile() Open MyFile For Output As fnum 'write project info and then a blank line. Note the comma is required Print #fnum, s Close #fnum End Sub
You need to login to post a comment.
