Word.Tips.Net Welcome toWord.Tips.Net

Helpful Links

Tips.Net Home
WordTips Home

Ask a Word Question
Make a Comment

Tips.Net Store

WordTips FAQ
WordTips Premium

Learn Access Now
Free Printable Forms

Beauty Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Legal Tips
Money Tips
Organizing Tips
Pest Tips
Pet Tips
Wedding Tips
Word2007 Tips
WordTips

Advertise on the
WordTips Site

Newest Tips

Arranging Document Windows

Specifying a Backup Location

Controlling Chart Gridlines

Merging Table Cells

Collapsing and Expanding Subdocuments

Zooming With the Keyboard

Initiating a New Search

 

Replacing Quoted Text with Italics with WordBasic

Summary: Got a document where lots of quoted text appears? Want to change all that quoted text to italics? This WordBasic macro makes short work of the task. (This tip works with Microsoft Word 6, and Word 95.)

In many word processors, an author may call out material with quote marks. For instance, the first time a term is introduced, the author may enclose the term in quote marks. In Word, however, you can call out information with italics. Manually changing quoted material to italics can be very time consuming, however. The following WordBasic macro, QuotesToItalics, will check the current paragraph for quoted material. If there is any, it will delete the quotes and change the text between the quotes to italics. If the quote marks are unbalanced (there is an opening or closing quote mark with no corresponding closing or opening quote mark), then the quote mark is ignored and no changes are made. The macro will work with either regular quotes or smart quotes.

Sub MAIN
If ExtendMode() Then Cancel
Redo = - 1
While Redo
    ParaDown 1, 1
    CharRight
    ParaUp 1, 1
    P$ = Selection$()
    Ptr = InStr(P$, Chr$(34))
    If Ptr = 0 Then
        Ptr = InStr(P$, Chr$(147))
    End If
    If Ptr > 0 Then
        CharLeft
        CharRight Ptr
        ParaDown 1, 1
        P1$ = Selection$()
        Ptr1 = InStr(P1$, Chr$(34))
        EndChar$ = Chr$(34)
        If Ptr1 = 0 Then
            Ptr1 = InStr(P1$, Chr$(148))
            EndChar$ = Chr$(148)
        End If
        If Ptr1 > 0 Then
            CharLeft
            EditClear - 1
            ExtendSelection EndChar$
            Cancel
            FormatFont .Italic = 1
            CharRight
            EditClear - 1
        Else
            CharRight
            Redo = 0
        End If
    Else
        CharRight
        Redo = 0
    End If
Wend
End Sub

Tip #263 applies to Microsoft Word versions: 6 | 95

Step Up and Take Control! Subscribers to WordTips know just how valuable a resource it is. WordTips Premium provides twice the number of exceptional, easy-to-understand tips every week in an ad-free newsletter, as well as substantial discounts on WordTips archives and e-books.
 
Check out WordTips Premium today!