I have always advocated linking to existing Word documents rather than duplicating the information inside the wiki except where the Word document is being replaced by the wiki page. In the later case this macro gives a useful starting point. --BrianHunter
I have added processing for table of contents...
add a call to ConvertTOC? after the H1/H2/H3 calls change the headings to be numbered headingsi.e. include a #
.InsertBefore? "== # "
.InsertAfter? " =="
make the headings 1 level less (as heading 1 is not included in a TOC)
i.e. heading 1 becomes heading 2; heading 2 becomes heading 3 etc
add this subroutine at the end of the macro
Private Sub ConvertTOC()
ActiveDocument.Select
With Selection.Find
.ClearFormatting
.Text = "Table of Contents"
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
.Forward = True
.Wrap = wdFindContinue
Do While .Execute
With Selection
If InStr(1, .Text, vbCr) Then
' Just process the chunk before any newline characters
' We'll pick-up the rest with the next search
.Collapse
.MoveEndUntil vbCr
End If
' Don't bother to markup newline characters (prevents a loop, as well)
If Not .Text = vbCr Then
.InsertBefore "<b>"
.InsertAfter "</b><toc>"
.Font.Bold = False
Exit Do
End If
End With
Loop
End With
End Sub