using environment variable in macro path

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
 
C

Chip Pearson

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top