Sub FormatIT()
' Open dialog to load the start sheet
With Dialogs(wdDialogInsertFile)
Dim defpath As String
'Get the present default filepath for documents
defpath = Options.DefaultFilePath(wdDocumentsPath)
'Change it to current meet reports directory
Options.DefaultFilePath(wdDocumentsPath) = "C:\SPORTSYS\SSMeet\Meets\ICMeet16\reports"
With Dialogs(wdDialogInsertFile)
.Name = "*.txt"
.Show
End With
'Change the default filepath for documents back to the original default
Options.DefaultFilePath(wdDocumentsPath) = defpath
End With
' Set columns and style
ActiveDocument.PageSetup.TextColumns.SetCount NumColumns:=1
ActiveDocument.Range(Start:=0).Style = "HeatStartList"
Selection.HomeKey Unit:=wdStory
Selection.MoveDown Unit:=wdLine, Count:=4, Extend:=wdExtend
Selection.Delete
icount = ActiveDocument.Paragraphs().Count
mcount = icount
lastpara = ""
'do for all paragraphs
For pcount = 1 To icount
' get the heat data
para = ActiveDocument.Paragraphs(pcount)
'0-9 fix - SDS 13/02/2010
If Left(para, 1) = "0" Then
GoTo carryon
End If
If Val(para) > 0 Then
carryon:
newpara = heat & Chr$(9) & "L "
If newpara = lastpara Then
newpara = Chr$(9) & "L "
Else
lastpara = newpara
End If
If Right(para, 3) = vbTab & vbCrLf Then para = Trim(Left(para, Len(para) - 3)) & vbCrLf
ActiveDocument.Paragraphs(pcount).Range = newpara & para
Else
' look for Event
para = ActiveDocument.Paragraphs(pcount)
If Left(para, 5) = "Event" Then
ActiveDocument.Paragraphs(pcount).Range.Style = "BoldTitles"
' Do not insert Cr before Event Title
' If pcount <> 1 Then
' ActiveDocument.Paragraphs(pcount).Range.InsertBefore vbCr
' mcount = mcount + 1
' pcount = pcount + 1
' End If
lastpara = ""
End If
' look for heat number and store it
para = ActiveDocument.Paragraphs(pcount)
If Left(para, 4) = "Heat" Or Left(para, 4) = "Fast" Or Left(para, 4) = "Semi" Or Trim(para) = vbCrLf Then
If Left(para, 4) = "Heat" Or Left(para, 4) = "Fast" Then heat = "H" & Str(Val(Right(para, 4)))
If Left(para, 4) = "Semi" Then heat = "S" & Str(Val(Right(para, 4)))
If Trim(para) = vbCrLf Then heat = "F "
With ActiveDocument.Paragraphs(pcount)
.Range.Delete
.Range.InsertAfter vbCr
End With
End If
para = ActiveDocument.Paragraphs(pcount)
If Left(para, 5) = "Final" Or Left(para, 7) = "B Final" Then
final = True
End If
' look for Lane header and delete it
para = ActiveDocument.Paragraphs(pcount)
If Left(para, 4) = "Lane" Then
ActiveDocument.Paragraphs(pcount).Range.Delete
mcount = mcount - 1
If final = True Then
pcount = pcount - 1
final = False
End If
End If
End If
If pcount = mcount Then Exit For
Next pcount
ActiveDocument.PageSetup.TextColumns.SetCount NumColumns:=2
ActiveDocument.PageSetup.TextColumns.EvenlySpaced = True
ActiveDocument.PageSetup.TextColumns.LineBetween = True
Selection.EndKey Unit:=wdStory
Selection.HomeKey Unit:=wdStory
'Delete Competitor Numbers'
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "\(*^t"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindEnd
.MatchWildcards = True
End With
Selection.Find.Execute Replace:=wdReplaceAll