Options:

1. change code to use late binding: Dim fso As Object

2. set VBA reference library Microsoft Scripting Runtime for early binding

Review https://www.automateexcel.com/vba/us...-in-excel-vba/

Edit code to use your folder path in place of "folderpath"