Monday, September 15, 2014

QTP VBS Excel SaveAs: how to save 2003 excel files (.xls) in the compatibility mode (2007 office Excel)



I have one qtp script and the come out result is default 2007 format .xlsx files and today I want to convert it to 2003 :


Just change the file name is xls and add number 56 or -4134 in the SaveAs codeline: see the below snippet:

          file_name=p_string&".xls"
            file_path="c:\1234\"
            new_file_location=file_path&file_name
            'obj_excel.ActiveWorkbook.SaveAs  new_file_location
           
            obj_excel.ActiveWorkbook.SaveAs  new_file_location,-4143
             

These are the main file formats in Excel 2007-2013, Note: In Excel for the Mac the values are +1

51 = xlOpenXMLWorkbook (without macro's in 2007-2013, xlsx)
52 = xlOpenXMLWorkbookMacroEnabled (with or without macro's in 2007-2013, xlsm)
50 = xlExcel12 (Excel Binary Workbook in 2007-2013 with or without macro's, xlsb)
56 = xlExcel8 (97-2003 format in Excel 2007-2013, xls)

Reference : 

http://stackoverflow.com/questions/17464698/open-an-excel-file-and-save-as-xls
http://www.rondebruin.nl/win/s5/win001.htm

No comments:

Post a Comment