Is there a compatibility issue between macros written for XLS, XLSX and XLSM?

calendar_today Asked Nov 10, 2011
thumb_up 7 upvotes
history Updated April 16, 2026

Question posted 2011 · +4 upvotes

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

Accepted answer +7 upvotes

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 In which case should we use the xlsm or the xlsb format? 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.

External references cited (4)

Top vba Q&A (6)

+7 upvotes ranks this answer #56 out of 81 vba solutions on this site .
vba