locked
About save method of Microsoft.Office.Interop.Excel.Workbook RRS feed

  • Question


  • Sample code:

    Microsoft.Office.Interop.Excel.Workbook theWorkbook =
    ExcelObj.Workbooks.Open(
    "C:\\test.xls", 0, true, 5,
    "", "", true, Excel.XlPlatform.xlWindows, "\t", false, false,
    0, true, null, null);
    Microsoft.Office.Interop.Excel.Sheets sheets = theWorkbook.Worksheets;
    Excel.Worksheet worksheet = (Excel.Worksheet)sheets.get_Item(1);
    Excel.Range rng1 = worksheet.get_Range("A1:A1", Type.Missing);
    rng1.Value2 = "TestVal";
    theWorkbook.Save();

    when save method is called a message is prompt "A file named 'test.xls' already exists in this location. Do you want to replace it?"
    I want to avoid that message, can anyone please help me how to do that.


    Thanks,
    Mushq
    Wednesday, June 11, 2008 9:28 AM

Answers

  •  First of all, in the Open method call, your third argument says that the excel file you opened is in readonly mode, Also, the tenth field(Editable) is set to false. Change these two to make it writable and then try executing the program.
    Wednesday, June 11, 2008 10:37 AM

All replies

  •  First of all, in the Open method call, your third argument says that the excel file you opened is in readonly mode, Also, the tenth field(Editable) is set to false. Change these two to make it writable and then try executing the program.
    Wednesday, June 11, 2008 10:37 AM
  • Thank you very much. :)
    Wednesday, June 11, 2008 10:41 AM