Excel – compatibility issue between macros written for XLS, XLSX and XLSM

excelvba

Is there a compatibility issue between macros written for XLS, XLSX and XLSM? Will the same macro work for all workbooks?

Best Answer

There are significant differences between these formats :

  • .XLS is intended to be used for Excel 2003 and above, so your VBA code needs to be backwards compatible for earlier versions of Excel (<2007)
  • .XLSX is the Excel 2007 format that cannot store VBA code.
  • .XLSM or .XLSB are the Excel 2007 format that allow you to save VBA code with the workbook. As Sydenam said, the differences between these two is the way the workbook is stored.

In short: .XLSB is the binary format (equivalent to .XLS for 2007+ version) whereas .XLSM is the OOXML format.

See When should the xlsm or xlsb formats be used? for more information.


Addendum for backward compatibility

I can't see any easy way to tell you how it can be backwards compatible, we can't be that generic. You can see on Ozgrid the new methods and properties that were added in Excel 2007. You can also find here some tips on how to develop on Excel 2007.

The Ozgrid page will give you the new elements of Excel 2007 and then will tell you what you shouldn't use if you wanted to be backwards compatible.

Related Topic