Category Archives: VBA Functions

VBA routine to show all environment variables

I asked myself what is in the source for the environment  routine

used in vba as such: environ(“environmentvariable”)?

 

For example, with VBA, you can find the path to ‘My documents’ like this:


 

I modified some code to show me the contents of whatever source this function is referencing.  This routine should show all the items in the table that stores the environment variables.  For example you can used the environ vba function to find the home path and calculate the location of the My Documents folder as well as some other useful pieces of information.

 

if you run the showenvironment routine you should get a response like this: