Category Archives: File and Folders

Using Application.Filedialog in Microsoft Excel VBA

What is the Application.FileDialog VBA function and how do you use it? Basically, it returns a FileDialog object instance of the dialog. This is similar to the functionality of the standard Open and Save dialog boxes found in Microsoft Office applications. Using these dialog boxes, users

The Excel VBA Application.FileDialog Object

Have you ever wished you could develop a simple way for users to select files to open from within Excel? Perhaps you want to impose a level of control over which file path users select the file(s) from. This can be done by using the

No Thumbnail

VBA, Modify Existing Text File

In this article I will explain how you can modify an existing text file. Jump To: Example 1, Overwrite Existing File With New Data Example 2, Modify Values in Text File Example 3, Adding Open and Save File Dialogs You can download the file and code related

No Thumbnail

VBA Folder Dialog

The folder dialog is a dialog that prompts the user to select a directory path. Jump To: Example Button Name, ButtonName Change Title, Title Start Path, InitialFileName You can download the file and code for this file here. Please note that although the sample file is for

No Thumbnail

VBA Excel, Writing to a Text File

In this article I will explain how you can write data to a text file. Jump To: Example 1, Write One Line of Data to Text File Example 2, Write Multiple Lines of Data to Text File Example 3, Save File Dialog Example 4, Check

No Thumbnail

Excel VBA, Reading Text Files

In this article I will explain how you can read data from a text file. You can download the workbook and code for this article here. Jump To: Example 1, Opening a Text File and Reading the First Line Example 2, Closing the Text File After Using

No Thumbnail

Excel VBA Save File Dialog, GetSaveAsFilename()

There may be times when you need to ask the user to select a location to save a file. This can be done using a save file dialog. Keep in mind that a save file dialogs doesn’t actually save anything. It only returns the full path

No Thumbnail

Find and List all Files and Folders in a Directory

In this article I will explain how you can  find and create a list of all the files and folder in a directory: Jump To: Get List of All Files Using, FileSystemObject Get List of All Folders Using, FileSystemObject Dir() Get List of All Files

No Thumbnail

VBA Delete File

In this article I will explain how you can delete files using VBA. – Basics: The code below will delete the file specified by the path associated to the variable strPath: Sub Example1() Dim ObjFso As Object Dim strPath As String ‘file path strPath = “D:StuffBusinessTempTempFile.xlsx” Set