I would suggest that you write a VBA (Visual Basic for
Applications) macro to do this. If you don't have any
VBA experience, try this:
Make a backup copy of your Normal.dot file.
Select "Tools / Macro / Visual Basic Editor" (or the
equivalent in your version of Word).
Select the "Normal" or "Normal.dot" project in the
Project pane on the left.
Select the command "Insert / New Module"
Paste the macro below into the new module (that is, all
of the text afer "**** START OF MACRO ****")
Now go back to Word, and open the document that you want
to reformat. Select "Tools / Macro / Macros". Select
the "FormatText" macro, and push the Run button.
- David M. Gauntt
**** START OF MACRO ****
Option Explicit
Public Sub FormatText()
Dim POS As Long
Dim myRange As Range
Set myRange = ActiveDocument.Range(0, 0)
POS = 0
While FindText(POS, myRange, "+")
myRange.Bold = True
Wend
POS = 0
While FindText(POS, myRange, "/")
myRange.Underline = True
Wend
POS = 0
While FindText(POS, myRange, "~")
myRange.Italic = True
Wend
End Sub
Private Function FindText(POS As Long, myRange As Range,
delimiter As String) As Boolean
Dim startBold, startUnderline, startItalic As Long
Dim startPos As Long, endPos As Long
FindText = False
startPos = FindString(POS, delimiter)
If startPos < 0 Then
Exit Function
End If
endPos = FindString(startPos + 1, delimiter)
If endPos < 0 Then
Exit Function
End If
' Delete the end delimiter
myRange.start = endPos
myRange.End = endPos + 1
myRange.Delete
' Delete the start delimiter
myRange.start = startPos
myRange.End = startPos + 1
myRange.Delete
endPos = endPos - 1
myRange.start = startPos
myRange.End = endPos
myRange.Select
FindText = True
End Function
Private Function FindString(ByRef startPos As Long,
theString As String) As Long
Dim myRange As Range
Set myRange = ActiveDocument.Range(startPos, startPos)
With myRange.Find
.Forward = True
.ClearFormatting
.MatchWholeWord = True
.MatchCase = False
.Wrap = wdFindContinue
If Not .Execute(FindText:=theString) Then
FindString = -1
Else
FindString = myRange.start
myRange.Select
End If
End With
End Function