#1   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 40
Default File Path

Help Needed.

I had developed a macro that was used by myself, however now the macro needs
to be utilised by others.

The marco opens files, that have been exported from the corporate database.
The files are saved automatically to the users C Drive eg. C:\Documents and
Settings\"username - logged on user"\help.xls

The only difference is the username in the file path.

Is there anyway that I can change the file path to automatically go to the
correct file, without having to create difference macros for each user.

Any help would be greatly appreciated.
  #2   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 2,646
Default File Path

VBA function Environ(29) returns the logged in user's name.

--
Regards!
Stefi



€˛Max2073€¯ ezt Ć*rta:

Help Needed.

I had developed a macro that was used by myself, however now the macro needs
to be utilised by others.

The marco opens files, that have been exported from the corporate database.
The files are saved automatically to the users C Drive eg. C:\Documents and
Settings\"username - logged on user"\help.xls

The only difference is the username in the file path.

Is there anyway that I can change the file path to automatically go to the
correct file, without having to create difference macros for each user.

Any help would be greatly appreciated.

  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
external usenet poster
 
Posts: 7,247
Default File Path

VBA function Environ(29) returns the logged in user's name.

Perhaps it does on your machine, but that is by no means a valid
assumption for any other machine. On this box, 29 is the processor
level value. Never use a numeric value to get an environment
variable's value. Use the name:

Debug.Print Environ("username")

Note also that there is a difference when getting an environment
variable's value by name or by number. When Environ is used with the
name, as in

Debug.Print Environ("username")

it returns only the value assigned to the variable. When retrieved by
number, as in

Debug.Print Environ(29)

Both the name and the value are returned, separated by an = character.
E.g,

Debug.Print Environ(29)

displays "PROCESSOR_LEVEL=6" rather than just "6".

Cordially,
Chip Pearson
Microsoft MVP 1998 - 2010
Pearson Software Consulting, LLC
www.cpearson.com
[email on web site]




On Mon, 7 Dec 2009 04:45:01 -0800, Stein
wrote:

VBA function Environ(29) returns the logged in user's name.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
File Path Max2073 Excel Worksheet Functions 1 December 10th 09 11:16 PM
File Path Max2073 Excel Worksheet Functions 2 December 7th 09 08:46 PM
Variabilize File Path or File Name in SumProduct (and Vlookup too) Mike H. Excel Worksheet Functions 2 January 7th 08 09:34 PM
Formula too long - new file path is shorter than old file path - Excel 2003 Greg J Excel Worksheet Functions 1 November 22nd 06 05:16 PM
Excel updating from XML file - file path specific? Sean Excel Discussion (Misc queries) 4 August 5th 05 12:56 PM


All times are GMT +1. The time now is 04:42 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"