Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Find and replace each occurence of text with msgbox.

Status
Not open for further replies.

hoppy186

Programmer
Dec 1, 2005
1
US
I need a code that will find an italicized word in a document and highlight it and pop up a message box to the user asking if they want to non-italicize it. The user clicks yes, no, or cancel then the code should find and highlight the next italicized word and pop up the message box again. I want this to happen throughout the whole document. Please help.
 
Try code below:

Code:
Public Sub FindAndHighlight()
    Dim x As Range, mr As VbMsgBoxResult
    For Each x In ThisDocument.Words
        If x.Italic = True Then
            x.Select
            mr = MsgBox("Do you want to remove italic effect?", vbYesNoCancel, "Remove Italic")
            If mr = vbCancel Then Exit Sub
            If mr = vbYes Then x.Italic = False
        End If
    Next
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top