Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
how do i delete a file from recent documents file in excel | New Users to Excel | |||
how can i output the file | Excel Programming | |||
Open CSV file, format data and write output to a text file. | Excel Programming | |||
Output to a file? | Excel Programming | |||
CSV output file | Excel Programming |