1

When I save files in C#, with the intent of overwriting or appending, I keep getting pesky "Are you sure you wanna overwrite x.file?" Which freezes a very long thread. This program needs this to not happen, is there a way to auto respond yes?

Any help appreciated.

var exWks = (Microsoft.Office.Interop.Excel.Worksheet)exWbk.Sheets["Sheet1"];
exWks.SaveAs(path);
BinkyNichols
  • 586
  • 4
  • 14
  • 1
    Use `xlApp.DisplayAlerts = false;` where `xlApp` is the `Excel.Application` object you used to create/open the workbook. – 41686d6564 stands w. Palestine Sep 02 '19 at 17:20
  • Perfect Ahmed, thank you, is there any way to do this for any popup though? But if you make it a answer I'll mark it answered. – BinkyNichols Sep 02 '19 at 17:31
  • 1
    Glad I was able to help! I will not post an answer because this was covered before. Instead, you may accept the linked question as duplicate. Regarding other popups, if you mean any popup in Excel, then `DisplayAlerts` should indeed affect all popups. If you mean any popup in general, then it's different. If it's a popup shown by your application, you have full control over it. If it's shown by a 3rd party application and it doesn't provide a way to hide it (like Excel does), then you'll either have to live with it or hack your way around it (e.g., using automation, `SendKeys`, etc.) – 41686d6564 stands w. Palestine Sep 02 '19 at 17:43

0 Answers0