using environment variable in macro path

  • Thread starter Thread starter M. Mix
  • Start date Start date
M

M. Mix

Hiho,

at first i am sorry for the double post but i hope to get an answer here
because some peaple don´t look in the programming newsgroup but do here...

I have a problem with a macro which is linked behind an excel button.
I want to use the environment variable %USERPROFILE% in the macro path
because the macro is been used from many users.

The path at this time is hard coded: C:\Dokumente und
Einstellungen\mmustermann\Eigene
Dateien\Anwendungsdaten\Microsoft\Excel\XLStart\PERSONL.XLS

I want to modify the path to:
%USERPROFILE%\Anwendungsdaten\Microsoft\Excel\XLStart\PERSONL.XLS

When i modify the path the result is the following: C:\Dokumente und
Einstellungen\mmustermann\Eigene
Dateien\%USERPOROFILE%\Anwendungsdaten\Microsoft\Excel\XLStart\PERSONL.XLS

Any hints how to solve this ?

Thx

Markus
 
Use the Environ function:

Dim FolderName As String
FolderName = Environ("UserProfile")
Debug.Print FolderName &
"\Anwendungsdaten\Microsoft\Excel\XLStart\PERSONL.XLS"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)
 
Back
Top