Return to VBA Code Examples

VBA – Validate Filenames

The following code will validate whether a filename is valid.  This is useful if your code requires a user inputted filename. It will verify that the filename is valid before proceeding and possibly generating an error.

Validate File Name

This function tests that the variable ‘FileName’ is a valid filename:

You can call the function like this:

This test procedure will output TRUE or FALSE to the Immediate Window.

VBA Coding Made Easy

Stop searching for VBA code online. Learn more about AutoMacro – A VBA Code Builder that allows beginners to code procedures from scratch with minimal coding knowledge and with many time-saving features for all users!

alt text

 

Learn More!


<<Return to VBA Examples