vbaCommon – GetEnv (Environment)

 

' ───────

Private Function getENV(strReturn As String)
  'Example ChDir getENV("userprofile") & "\Desktop\"
Dim EnvString, Indx, Msg, PathLen    ' Declare variables.
For Indx = 1 To Len(Environ(Indx)) + 2
    EnvString = Environ(Indx)  ' Get environment
    If UCase(Left(EnvString, Len(strReturn))) = UCase(strReturn) Then
      getENV = Mid(EnvString, Len(strReturn) + 2)
    End If
 Next Indx 'Loop Until EnvString = ""

End Function
' ───────

Leave a Reply

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