简体   繁体   English

Excel.Workbook单击取消引发异常

[英]Excel.Workbook clicking cancel throws exception

I am trying to save some data to an excel sheet. 我正在尝试将一些数据保存到Excel工作表中。

I did everything correct, but now when I want the use to select a file to save one. 我所做的一切都正确,但是现在当我想使用它来选择要保存的文件时。 I use this code 我用这个代码

xlWorkBook.SaveAs(fileNameToSave, Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);

If the file already exists, the code produces a notification that shows: "do u want to replace the file?" 如果文件已经存在,则代码将生成一条通知,显示:“您要替换文件吗?”

Is there any possibility that this message doesn't appear? 该消息有可能不会出现吗? Because I handled the existing files already. 因为我已经处理了现有文件。

I guess you are looking for Application.DisplayAlerts property. 我猜您在寻找Application.DisplayAlerts属性。 You can set that to false. 您可以将其设置为false。 Read here for details. 阅读此处了解详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM