Call export to spreadsheet from a function

Call export to spreadsheet from a function

Is there a way to call the export to spreadsheet command, based on criteria, from a custom function? I have a form with a field called Print_Label that is either True or False, default being set to True. I need to export all records where Print_Label is True to a spreadsheet, then set the Print_Label field to False. The later is easy to do with a function, but I don't see a way to trigger the export to spreadsheet option, or to do so based on criteria.