Home
FREE DOWNLOADS
VBA Tutorials
VBA CodeSamples
VBA for Beginners
Save Time News
Outlook Tutorials
Save Time Blog
SaveTime SiteMap
Excel VBA Code
PageNotActive
Other Tutorials
About This Website

Subscribe To This Site
XML RSS
Add to Google
Add to My Yahoo!
Add to My MSN
Subscribe with Bloglines



VBA and Replace



Sub VBA_and_Replace()
    ' Start searching at the beginning of the document.
    Selection.HomeKey wdStory
    ' Clear any previous formatting that was used in the Find and Replace dialog
    ' If you wanted to search/find for or Replace with Bold text, you could add
    ' to the With block .Font.Bold = True or .Replacement.Font.Bold = True respectively.
    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = "True"
        .Replacement.Text = "False"
        .Forward = True
    ' Answer the dialog that asks to seach from the beginning when the end is reached.
    ' Options are wdFindAsk, wdFindContinue, and wdFindStop
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchKashida = False
        .MatchDiacritics = False
        .MatchAlefHamza = False
        .MatchControl = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
End Sub



Google


Return from VBA and Replace to VBA Code Samples


Return to our Homepage


footer for Save Time page