Sub Main ' Open the database. Set db = Client.OpenDatabase("\\Path\Statutory_Comp_Codes.IMD") ' Create the task. Set task = db.ExportDatabase ' Configure the task. task.IncludeAllFields ' I want to repeat this for several COMP_CODE, and extract to a separate file. I don't mind copy pasting and editing several times and then running the script once, 'would be nice if I could use something like an array to automate and not copy paste but can live with copy paste for now eqn = " COMP_CODE == ""DK10""" task.PerformTask "\\Path\Statutory_Comp_Codes_DK10.XLSX", "Database", "XLSX", 1, db.Count, eqn ' Clear the memory. Set task = Nothing Set db = Nothing ' Open the result. End Sub