View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Saving to users My Documents

Just to Add to Rob's excellent example, to demonstrate late binding
(reference not required)

Sub SetMyDocs()
Const SPECIAL_FOLDER_MY_DOCS As Long = 16
Dim o As Object
Set o = CreateObject("WScript.Shell")
MsgBox o.SpecialFolders(SPECIAL_FOLDER_MY_DOCS)
End Sub

--
Regards,
Tom Ogilvy

"Rob Bruce" <robatanalytical-dynamicsdotcodotyoukay wrote in message
...
Rob Edwards wrote:
Hi,
When creating code to save a file, how do you specify a users 'My
Documents' folder so that it is determined at run time. Therefore,
dependent on the user, the file will be saved in their C:\Documents
and Settings\'user'\My Documents\, i.e. in my case... C:\Documents and
Settings\REdwards68584\My Documents\

I'm sure it must be easy!

Thanks in advance.

Rob


This works for me - requires a reference to the Windows Scripting Host
Object Model.

Sub SetMyDocs()
Const SPECIAL_FOLDER_MY_DOCS As Long = 16
Dim o As New IWshRuntimeLibrary.WshShell
MsgBox o.SpecialFolders(SPECIAL_FOLDER_MY_DOCS)
End Sub

HTH
--
Rob

http://www.asta51.dsl.pipex.com/webcam/