Searches for a string specified by the search parameter, and replaces it with the string specified by the replaceWith parameter. The search string can be a literal, a regular expression, or a combination of both. Since the string can contain regular expressions, use a backslash to escape special characters. Special characters are [^$.|?*+().

 public virtual int SearchAndReplace(System.String search, System.String replaceWith)
Public Overridable Function SearchAndReplace(ByVal search As String, ByVal replaceWith As String) As Integer

The string to find and replace.

The replacement string.

The number of occurences that were found and replaced.


          WordApplication app = new WordApplication();
          Document doc = app.Open(@"C:\myDoc.doc");

          //--- Update a copyright
          //--- Search for: (c) or the copyright symbol in ASCII, one or more whitespace characters,
          //--- four digits, and then any number of characters followed by 'Inc.'
          //--- Replace matches with '(c) 2008 SoftArtisans, Inc.'
          doc.SearchAndReplace("(\(c\)|\xA9)\s+[0-9]{4}\s+SoftArtisans, Inc\.", "(c) 2008 SoftArtisans, Inc.");
        

          Dim app As New WordApplication()
          Dim doc As Document = app.Open("C:\myDoc.doc")

          '--- Update a copyright
          '--- Search for: (c) or the copyright symbol in ASCII, one ore more whitespace characters,
          '--- four digits, and then any number of characters followed by 'Inc.'
          '--- Replace matches with '(c) 2008 SoftArtisans, Inc.'
          doc.SearchAndReplace("(\(c\)|\xA9)\s+[0-9]{4}\s+SoftArtisans, Inc\.", "(c) 2008 SoftArtisans, Inc.")