title: replace cell values within excel using excel.interop
body: <p>I want to scan an excel sheet, and replace any occurrences of social security numbers with zeros... I would like to do this using Excel.Interop if at all possible, but I'm open to anything at this point... here's some of my code... I'm banging my head on the desk for the past few months...</p>
  
  <pre>
   // Get range and convert it to a string variable 
              Excel.Range _range =(Excel.Range)_excelApp.get_Range("A1:K1",Type.Missing);
  
              // convert the value of our cells in our range
              // to the string variable
              string myString = _range.Cells.Value2.ToString();          
  
              // match any SSN e.g. 1236780909, 123-33-2445
              if (Regex.IsMatch(myString, @"\b\d{3}\b\d{2}\b\d{4}"));
              {                
                  _range.Cells.Value2 = replaceSSN;
              }
  
              // save our workbook with a new name and create a backup
              _excelWorkbook.SaveAs("Results.xls", Type.Missing, Type.Missing, Type.Missing, Type.Missing, true, Excel.XlSaveAsAccessMode.xlNoChange, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
  
              // close workbook
              _excelWorkbook.Close(false, Type.Missing, Type.Missing);
  
              // send quit signal to app
              _excelApp.Quit();
  
              // report success            
              MessageBox.Show("File masked successfully.", "Mask Data", MessageBoxButtons.OK);
  
              // release memory
              //System.Runtime.InteropServices.Marshal.ReleaseComObject(_excelApp);
  
              // change label back to being blank
              lblActivity.Text = "";
          }      
  </pre>