Environment Variables

In many macros you need access active session environment settings like username, computer name, etc. The easiest way to do this is using Windows environment variables. To see what environment variables are available open a Command Prompt window and enter the SET command. Some of the more common examples are shown in the code sample below:

Sub MyMacro()
Dim strUsername As String
Dim strComputername As String
Dim strTempFolder As String
Dim strUserProfile As String

strUsername = Environ$(“USERNAME”)
strComputername = Environ$(“COMPUTERNAME”)
strTempFolder = Environ$(“TEMP”)
strUserProfile = Environ$(“USERPROFILE”)

End Sub


EnvisionCAD

EnvisionCAD

Since 1996, EnvisionCAD has been a nationally recognized leader in the configuration, customization, implementation, training & support for CAD software solutions. Our individualized approach has benefited private engineering firms and government agencies alike. Basic or advanced, we can help you get the most from your CAD technology.

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *