bottom
Great WordTips!
         
Your e-mail address is safe!
Close Note

Tips.Net > WordTips Home > Formatting > Character Formatting > Replacing Quoted Text with Italics with WordBasic

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


Take Control! Master the real power behind Word! Successfully master the secrets of powerful formatting and create documents that stand out from the rest. Best of all, you can create documents that are easy to maintain and quick to change.
 
Check out Word 2007 Styles and Templates today!

Helpful Links

Ask a Word Question
Make a Comment

Tips.Net Home
Tips.Net Store

WordTips FAQ
WordTips Premium

Learn Access Now

Beauty Tips
Bugs and Pests Tips
Car Tips
Cleaning Tips
College Tips
Cooking Tips
Excel2007 Tips
ExcelTips
Family Tips
Gardening Tips
Health Tips
Home Tips
Money Tips
Organizing Tips
Pet Tips
Word2007 Tips
WordTips

Advertise on the
WordTips Site

 

Great Info!

Get tips like this every week in WordTips, a free productivity newsletter. Enter your e-mail address and click "Subscribe."
     
(Your e-mail address will never be shared with anyone, ever.)