Thread: Macro for Word
View Single Post
Old 11-18-2008, 07:39 PM   #2 (permalink)
David M58
Registered User
 
Join Date: May 2008
Location: Baltimore, Maryland
Posts: 160
OS: Windows XP SP3


Re: Macro for Word

Here is some code I threw together quickly. It underlines words contained within quotation marks. The code could use a little work, though, so go ahead and make improvements as you see fit!

Code:
Sub Underline()
    Dim idx As Long
    Do While idx < ActiveDocument.Words.Count
        idx = idx + 1
        Select Case Trim(ActiveDocument.Words(idx))
            Case Chr(147), Chr(148), Chr(34)
                If Not ((idx + 2) > ActiveDocument.Words.Count) Then
                    Select Case Trim(ActiveDocument.Words(idx + 2))
                        Case Chr(147), Chr(148), Chr(34)
                            ActiveDocument.Words(idx + 1).Underline = wdUnderlineSingle
                            idx = idx + 1
                    End Select
                End If
        End Select
    Loop
End Sub
David M58 is offline   Reply With Quote