我有一个 .Net 项目,可以在 Excel 工作簿之间自动传输信息。该代码打开一个 Excel 2010 应用程序,打开一个 xlExcel8 格式的工作簿,创建一个 xlExcel8 格式的空白工作簿并将页面从第一个工作簿传输到空白工作簿。即使我使用了 DoNotPromptForConvert 命令,我在保存空白工作簿时也无法抑制弹出消息。我一直在使用的代码是:
private static void QuickTest()
{
Object M = Type.Missing;
string FullFileName2 = "C:\\Users\\Bill Corry\\Venrock\\SusansProject\\Test.xls"; //blank WkbkName
string FullFileName = "C:\\Users\\Bill Corry\\Venrock\\SusansProject\\VRQtrCompInfoReqv8.xls"; //Template
XLHlpr XLH = new XLHlpr(); // start a helper class
XL.Workbook srcWkBk = XLH.OpenExistingWorkbook(FullFileName, false); //open WkBk with Format xlExcel8
srcWkBk.DoNotPromptForConvert = true; //try to suppress pop-up message
XL.Workbook WkBk = XLH.GetNewWorkbook(); //open blank workbook
WkBk.DoNotPromptForConvert = true;
WkBk.SaveAs(FullFileName2, XL.XlFileFormat.xlExcel8, M, M, M, M, XL.XlSaveAsAccessMode.xlNoChange, M, M, M, M, M); //no popup here
//Copy Worksheet from first file to blank workbook
XL.Worksheet WkSht = (XL.Worksheet)srcWkBk.Worksheets[1];
WkSht.Copy(WkBk.Worksheets[1], M);
WkBk.DoNotPromptForConvert = true;
WkBk.Save(); //Popup occurrs on this step
WkBk.Close(false, M, M);
srcWkBk.Close(M, M, M);
}