Create an Excel file from BOM when drawing opened or closed

Is there a way to have the Solidworks drawing create an Excel spreadsheet file of the BOM from each page when you close or open the drawing file?

SolidworksBill Of Materials