Hi

I have a textbox and a button on a html page. On click of button I want to save the value in the textbox to a particular cell of the excel file

I have written the following code

var ExcelSheet = new ActiveXObject("Excel.Application");


        ExcelSheet.Workbooks.Open("D:\\TEST.XLS");
       
        // Make Excel visible through the Application object.
        ExcelSheet.Application.Visible = false;
       
        // Place some text in the first cell of the sheet.
        ExcelSheet.ActiveSheet.Cells(2,1).Value = document.forms[0].txtName.value ;
       
       
        // Save the sheet.
        ExcelSheet.Save();
        
        ExcelSheet.DisplayAlerts = false;
        // Close Excel with the Quit method on the Application object.
        ExcelSheet.Application.Quit();
        // Release the object variable.
        ExcelSheet = "";

Everything works fine. The value is stored in excel but when I click the button to save I am getting a message

"A file named 'RESUME.XLW' already exists in this location. "

I have also written

ExcelSheet.DisplayAlerts = false;

But still I am getting the message.

Why this message is coming and what is the way to supress it.

Kindly advice

Regards

Karan

You can't supress it because it's a System alert! You are overwriting an existing file.

Try: ExcelSheet.Workbooks.Open("D:\\TEST.XLS", 2, true);

Hi

I have implemented your code but after that I am not able to save the excel file implicitly through the application, my system asks me to save the file explicitly.

Regards
Karan

Yeah that's also a system precaution measure...
I haven't been using this functionality for about 6-7 years now.
I'm not sure,
try ExcelSheet.SaveAs("D:\\TEST.XLS"); , that might supress the confirmation. Or simply close the document with quit command.

The .xlw exists when there are recovery versions that haven't been reconciled...I created a few to test. When I put the statement before the save, it stopped giving me the message.

xlApp.AlertBeforeOverwriting = False
xlApp.DisplayAlerts = False
xlApp.Save()

if you are getting this message you are lucky because .if you delete EXCEL.SAVE LINE.AND USE EXCEL.QUIT INSTEAD YOU WILL STILL GET A SAVE AS DILOGUE BOX .THE MESSAGE WONT COME BUT WHEN EVER YOU CLOSE YOUR PROJECT EXCEL WILL STILL BE HANGING IN MEMORRY.USING SAVEWORKSPACE BEFORE EXCEL.QUIT RELEASES EXCEL FROM MEMORRY.
tHIS IS A MEMMORY LEAK

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.