Forum Discussion

NisHera's avatar
NisHera
Valued Contributor
8 years ago

Writing to excel compatible files

Hi,

My application creates a excel report in old version 97-2003 work sheet.

to run the test I need to add couple of line into it.

 

The new test machine has Excel 2016.

I used to open and write using ..

 var app = Sys.OleObject("Excel.Application")
var book = app.Workbooks.Open(fname);
var sheet = book.Sheets(sheetName);
..............
app.Visible = true;
xlRange = app.Range('A1').Activate();
app.ActiveCell.EntireRow.Insert(); //.Insert();
for(i=1;i<18;i++){ app.Cells(1,i)= headVal[i] }
.....................
book.Save();
Delay(7000);
app.Quit();

But now it doesn't work.

Opens in compatibility mode, can see writing (many lines ...) but discarded while saving.

 

any solutions?

 

  • It was my silly mistake..

     

    Code is working perfectly...

    it was parameter "fname" missing a '\' inside

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    > But now it doesn't work.

    What exactly does not work?

    File cannot be opened in Excel 97-2003 after save, or changes are lost and not saved, or file cannot be opened at all, or test code fails with some error, or... ?

      • NisHera's avatar
        NisHera
        Valued Contributor

        It was my silly mistake..

         

        Code is working perfectly...

        it was parameter "fname" missing a '\' inside