Manipulating filenames in Excel or Access, or VB/A

Do you often need to manipulate filenames in VBA ?
Here’s a small set of very useful functions that I regularly use:

GetFileExt

Get the file extension part of a filename, without the leading dot (“.”).

Example (type in immediate window):

 

StripFileExt

Get the left part of a filename (and path), without the file extension part.

Example (type in immediate window):

 

StripFilePath

Get only the filename of a full or partial filename and path.

Example (type in immediate window):

 

StripFileName

Get only the denormalized(*) path of a full or partial filename and path.

Example (type in immediate window):

(*)denormalized: without a path separator (“\”) at the end.

 

ChangeExt

Change the current extension of a filename (ex. “pdf” in c:\temp\test.pdf) to the specified new extension, and return the new filename.

Example (type in immediate window):

 

Code