View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
JP[_4_] JP[_4_] is offline
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.