
The example macros below cover two scenarios We will ensure the library is opened when we need it within the VBA code. Late Binding does not require any specific actions to enable the FSO Library. In the Visual Basic Editor, click Tools -> References…įrom the References – VBAProject window select the Microsoft Scripting Runtime option, then click OK. Early BindingĮarly Binding will open the FSO library as soon as the workbook opens.
/excel-file-extensions-file-formats-save-as-dialog-box-56c8bb375f9b5879cc44b379.jpg)
It may result in slower code, but it should run with less errors. If you’re not sure which to use, then I recommend using Late Binding. There are two ways to turn on the FSO library, known as Early or Late Binding. The File System Object (FSO) is a separate library of actions which we can enable to use within our VBA code. The Dir function is easy to use and does not require any special actions to enable it within the Visual Basic Editor.

The Dir function is a built-in VBA function, meaning it works with Excel, PowerPoint and Word In fact, it will work anywhere where VBA is available.
#PRINT FILE NAME ON EXCEL FOR MAC CODE#
Let’s briefly look at each of these before we start looking at the code to loop through files. VBA provides us with a few ways to achieve it (1) Dir function (2) File System Object. Listing filenames in a worksheet, printing all the files to PDF, or making changes to every file in a folder, there are many reasons why we may want to loop through each file in a folder.
