Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Output file to My Documents

I'm trying to write a macro in a file located on a shared drive that will be
used by various members of my team. It needs to Open a file for Output and
I'd like it to save the file to the My Documents folder of whoever is running
the macro. Is there a way to do this either using the UserName in the file
name or can "My Documents" be identified without putting a full path (ie
c:\Documents and Settings\username\My Documents\...)? I'm using Excel 2003.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,494
Default Output file to My Documents


this has always worked for me. some say it doesn't, but i've never had any
issues.

environ("UserProfile") & "\My Documents\"

--


Gary


"scdallas" wrote in message
...
I'm trying to write a macro in a file located on a shared drive that will be
used by various members of my team. It needs to Open a file for Output and
I'd like it to save the file to the My Documents folder of whoever is running
the macro. Is there a way to do this either using the UserName in the file
name or can "My Documents" be identified without putting a full path (ie
c:\Documents and Settings\username\My Documents\...)? I'm using Excel 2003.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 897
Default Output file to My Documents

Modified from an old Dave Peterson post:

Dim strMyDoc As String

strMyDoc = MyDocPath

Function MyDocPath() As String
' returns path to "My Documents" as a String
Dim WSHShell As Object

Set WSHShell = CreateObject("WScript.Shell")
MyDocPath = WSHShell.SpecialFolders("MyDocuments")

Set WSHShell = Nothing
End Function

ActiveWorkbook.SaveAs strMyDoc & "\" & "myfile.xls"


--JP

On Sep 23, 12:13*pm, scdallas
wrote:
I'm trying to write a macro in a file located on a shared drive that will be
used by various members of my team. *It needs to Open a file for Output and
I'd like it to save the file to the My Documents folder of whoever is running
the macro. *Is there a way to do this either using the UserName in the file
name or can "My Documents" be identified without putting a full path (ie
c:\Documents and Settings\username\My Documents\...)? *I'm using Excel 2003.


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Output file to My Documents

Thanks so much! It worked for me! I simply substituted
environ("UserProfile") in the portion of my Open statement where I had
hard-coded the location of MY My Documents folder and sure enough, my output
file was where I expected it to be!

Sue

"Gary Keramidas" wrote:

this has always worked for me. some say it doesn't, but i've never had any
issues.

environ("UserProfile") & "\My Documents\"

--


Gary


"scdallas" wrote in message
...
I'm trying to write a macro in a file located on a shared drive that will be
used by various members of my team. It needs to Open a file for Output and
I'd like it to save the file to the My Documents folder of whoever is running
the macro. Is there a way to do this either using the UserName in the file
name or can "My Documents" be identified without putting a full path (ie
c:\Documents and Settings\username\My Documents\...)? I'm using Excel 2003.




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
how do i delete a file from recent documents file in excel exile New Users to Excel 1 March 7th 09 01:59 AM
how can i output the file [email protected] Excel Programming 1 January 25th 07 05:14 AM
Open CSV file, format data and write output to a text file. BristolBloos Excel Programming 1 October 18th 05 03:50 PM
Output to a file? Kevin Burton Excel Programming 4 October 4th 05 03:57 AM
CSV output file Suzanne[_5_] Excel Programming 2 March 4th 05 05:03 PM


All times are GMT +1. The time now is 07:30 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"