Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default userid in macro

I have a macro that opens a file on my desktop and references the full
pathname including my id. Is there a way to convert this so that anyone can
use it?
example:
Workbooks.OpenText Filename:= "C:\Documents and
Settings\myid\Desktop\assys.txt",...

We all will have the same pathname with the exception of "myid"

Thanks for your help,
Mary Ann
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default userid in macro

in the vb editor, type the following in the immediate pane and press enter (if
it's not visible, hit control-G or click on view then immediate window)


?environ("userprofile")

--


Gary


"mmccoog" wrote in message
...
I have a macro that opens a file on my desktop and references the full
pathname including my id. Is there a way to convert this so that anyone can
use it?
example:
Workbooks.OpenText Filename:= "C:\Documents and
Settings\myid\Desktop\assys.txt",...

We all will have the same pathname with the exception of "myid"

Thanks for your help,
Mary Ann



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default userid in macro

sorry hit send too fast

Workbooks.OpenText Filename:=(Environ("userprofile") & "\Desktop\assys.txt")

--


Gary


"mmccoog" wrote in message
...
I have a macro that opens a file on my desktop and references the full
pathname including my id. Is there a way to convert this so that anyone can
use it?
example:
Workbooks.OpenText Filename:= "C:\Documents and
Settings\myid\Desktop\assys.txt",...

We all will have the same pathname with the exception of "myid"

Thanks for your help,
Mary Ann



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default userid in macro

That worked! Thanks Gary.

"Gary Keramidas" wrote:

sorry hit send too fast

Workbooks.OpenText Filename:=(Environ("userprofile") & "\Desktop\assys.txt")

--


Gary


"mmccoog" wrote in message
...
I have a macro that opens a file on my desktop and references the full
pathname including my id. Is there a way to convert this so that anyone can
use it?
example:
Workbooks.OpenText Filename:= "C:\Documents and
Settings\myid\Desktop\assys.txt",...

We all will have the same pathname with the exception of "myid"

Thanks for your help,
Mary Ann




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,501
Default userid in macro

Try:-

UserProfileFolder = Environ("UserProfile")

To return the user-profile and incorporate the variable into the path

Workbooks.OpenText Filename:= "C:\Documents and Settings\" &
UserProfileFolder &" myid\Desktop\assys.txt",..

Mike

"mmccoog" wrote:

I have a macro that opens a file on my desktop and references the full
pathname including my id. Is there a way to convert this so that anyone can
use it?
example:
Workbooks.OpenText Filename:= "C:\Documents and
Settings\myid\Desktop\assys.txt",...

We all will have the same pathname with the exception of "myid"

Thanks for your help,
Mary Ann



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default userid in macro

Mike,
I'm getting an error on this format:
Run-time error '1004':
Method "OpenText' of object 'Workbooks' failed

Here's what I tried:
UserProfileFolder = Environ("UserProfile")

Workbooks.OpenText Filename:="C:\Documents and Settings\" &
UserProfileFolder & " \Desktop\assys.txt", ...

"Mike H" wrote:

Try:-

UserProfileFolder = Environ("UserProfile")

To return the user-profile and incorporate the variable into the path

Workbooks.OpenText Filename:= "C:\Documents and Settings\" &
UserProfileFolder &" myid\Desktop\assys.txt",..

Mike

"mmccoog" wrote:

I have a macro that opens a file on my desktop and references the full
pathname including my id. Is there a way to convert this so that anyone can
use it?
example:
Workbooks.OpenText Filename:= "C:\Documents and
Settings\myid\Desktop\assys.txt",...

We all will have the same pathname with the exception of "myid"

Thanks for your help,
Mary Ann

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
Userid Marvin Excel Programming 4 March 14th 07 07:55 PM
How can I get network userid in a cell in excel? Kalpana_Kar Excel Programming 2 March 29th 06 11:16 PM
Log UserID JJ Excel Programming 3 March 9th 05 01:30 PM
DSN UserId and Password Prompt bslater[_13_] Excel Programming 0 September 22nd 04 09:02 PM
DSN UserId and Password Prompt bslater[_12_] Excel Programming 1 September 22nd 04 08:30 PM


All times are GMT +1. The time now is 11:42 AM.

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"