Option Explicit Sub Main Dim level As Integer 'current depth of map, level 0=maintopic Dim doc As Document 'document being exported Dim filename As String 'filename of destination text file Dim atopic As Topic 'main topic variable Dim result As String 'result string Dim availfortagging As String 'TRUE = Is available for tagging Set doc=ActiveDocument filename=GetPath(mmDirectoryMyMaps)& "Export-" & doc.CentralTopic.Text & ".csv" 'write output files in default directory Open filename For Output As #1 Print #1, """Term Set Name"",""Term Set Description"",""LCID"",""Available for Tagging"",""Term Description"",""Level 1 Term"",""Level 2 Term"",""Level 3 Term"",""Level 4 Term"",""Level 5 Term"",""Level 6 Term"",""Level 7 Term""" If doc.CentralTopic.AllIcons.ContainsStockIcon(mmStockIconFlagBlack)Then 'Is there a black flag in this topic? 'Black Flag means that this term is part of the hierarchy, but not available for tagging availfortagging="""False""" Else availfortagging="""True""" End If If Len(doc.CentralTopic.Notes.Text)>0 Then 'If there is a note attached to the topic, use it as the description Print #1, """" & doc.CentralTopic.Text & """,""" & doc.CentralTopic.Notes.Text & """,," & availfortagging & ",,,,,,,," 'Print the description of the topic Else Print #1, """" & doc.CentralTopic.Text & """,,," & availfortagging & ",,,,,,,," 'Don't bother with the description End If result="" level=0 DrillDown level, doc.CentralTopic, result 'call main subroutine Print #1 Close #1 MsgBox "Done! File located here: " & filename End Sub Sub DrillDown(slevel As Integer, stopic As Topic, sresult As String) 'DrillDown is a recursive subroutine that walks the taxonomy tree Dim qlevel As Integer 'Local Level Dim qtopic As Topic 'Local Topic Dim qavailfortagging As String Dim I As Integer 'Loop Counter for extra commas Dim prevresult As String 'Keep track of previous result when walking back up the tree If slevel=0 Then 'xxx do a bunch of stuff and drill down slevel=slevel+1 For Each qtopic In stopic.SubTopics DrillDown slevel,qtopic,sresult Next Else prevresult=sresult 'Hold a copy of the result string slevel=slevel+1 'Increment the level sresult=sresult & ",""" & stopic.Text & """" 'Add the new topic onto the result string If stopic.AllIcons.ContainsStockIcon(mmStockIconFlagBlack)Then qavailfortagging="""False""" Else qavailfortagging="""True""" End If If Len(stopic.Notes.Text)>0 Then 'Add the description from the notes (if there is one) Print #1, ",,," & qavailfortagging & ",""" & stopic.Notes.Text & """" & sresult; Else Print #1, ",,," & qavailfortagging & "," & sresult; 'No description, output the result End If For I = 1 To 8-slevel 'Add the extra commas as required based on level Print #1,","; Next I Print #1 For Each qtopic In stopic.SubTopics 'Process the next set of branches below us DrillDown slevel,qtopic,sresult 'This is the magic recursive call Next sresult=prevresult slevel=slevel-1 End If End Sub