Forum Discussion

ASV's avatar
ASV
Contributor
13 years ago

SaveAs Excel file

HI 

My exe (which I am testing now) is generating a Excel file.

I want to save this Excel file to a specific folder.

I write this code


   

Set objExcel = Sys.OleObject("Excel.Application")

      objExcel.SaveWorkspace(strpath)

      objExcel.Quit

      objExcel = Null


But then I can't open it.

I have a message "Excel cannot open the file 'Name.xlsx' because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file."

I think that this problem linked to my code. What to do open the Excel file?

Thanks in advance

2 Replies

  • Hi,



    The SaveWorkspace method is not related to TC, and it is unlikely that the problem is in your code. Most probably, it is somehow related to Excel's current state.



    Try using the Workbook.Save method.



    Also, since 'objExcel' is an object variable, assigning it to Null is not a good approach. Assign it to Nothing instead.