user1165596
user1165596

Reputation: 13

Deleting drop down boxes from an Excel file using Interop.Excel

I need to delete a drop down box from an excel sheet. I've tried searching for the formula value, deleting the cell value, deleting it from the macro and nothing works. Any suggestions would be appreciated. The client would like this update today. Thanks!

Upvotes: 1

Views: 1173

Answers (2)

Suresh Mahawar
Suresh Mahawar

Reputation: 1578

I tried this one. It works for me.

   var cell = (Microsoft.Office.Interop.Excel.Range)oSheet.Cells[row, column];
   cell.Validation.Delete();
   cell.Validation.Add(
      XlDVType.xlValidateInputOnly,
      Type.Missing,
      Type.Missing,
      Type.Missing,
      Type.Missing);
   cell.Value = "";
   cell.Validation.IgnoreBlank = false;
   cell.Validation.InCellDropdown = false;

Upvotes: 1

Steve
Steve

Reputation: 543

You might take a look at the Delete method of the Validation object -- e.g.,

        Excel.Range range = wksht.get_Range("A1", "A1"); 
        range.Validation.Delete(); 

Upvotes: 0

Related Questions