'*************************************
' A macro to insert your keywords into a document.  Reads KEYS.CSV, created by KeyCollector.
'*************************************
Sub MAIN
FileNew .NewTemplate = 0, .Template = "normal.dot"

FormatTabs .Position = "", .DefTabs = "0.5" + Chr$(34), .Align = 0, .Leader = 0, .ClearAll
FormatTabs .Position = "1.5" + Chr$(34), .DefTabs = "0.5" + Chr$(34), .Align = 0, .Leader = 0, .Set
FormatTabs .Position = "3" + Chr$(34), .DefTabs = "0.5" + Chr$(34), .Align = 0, .Leader = 0, .Set

FormatParagraph .Alignment = 0, .LeftIndent = "3" + Chr$(34), .RightIndent = "0" + \
Chr$(34), .FirstIndent = "-3" + Chr$(34), .Before = "2 pt", .After = "0 li", .LineSpacing = \
"0 li", .PageBreak = 0, .KeepWithNext = 0, .KeepTogether = 0, .NoLineNum = 0


Dim a$, b$, c$, done, n
Open "keys.csv" For Input As #1
Insert "Key Word" + Chr$(9) + "Filename" + Chr$(9) + "Topic title"
InsertPara
StartOfDocument : ParaDown 1, 1
FormatCharacter .Bold = 1
ParaDown
done = 0
While done = 0
	Read #1,  a$, b$, c$
	done = Eof(1)
	Insert a$ + Chr$(9) + c$ + Chr$(9) + b$
	InsertPara
Wend

Begin Dialog UserDialog 490, 66, "Keyword Sorting"
	Text 10, 6, 451, 13, "Would you like to sort the file by keyword, or leave it as is?"
	PushButton 94, 30, 143, 21, "Sort by keyword"
	PushButton 254, 30, 143, 21, "Leave unsorted"
End Dialog

Dim dlg As UserDialog
n = Dialog(dlg)
Select Case n
	Case 0
	Case 2
		Goto nuthin
	Case 1
		sortdoc
nuthin:
End Select
End Sub

Sub sortdoc
	StartOfDocument 1
	ParaDown 1, 1
	ToolsSorting .Order=0,.Type=0,.Separator=0,.SortColumn=0, \
	.CaseSensitive = 0
End Sub

