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

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

Rob Edwards

07092 108121

*** Sent via Developersdex
http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 65
Default Saving to users My Documents

Rob,

You can determine the username path from one of the environment variables.
You can cycle through them with the following code:

Sub allEnviron()
z = 1
doagain:
On Error GoTo Quitapp
Debug.Print Environ(z) & " : # " & z
z = z + 1
GoTo doagain
Quitapp:
End Sub

http://HelpExcel.com

"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

Rob Edwards

07092 108121

*** Sent via Developersdex
http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default Saving to users My Documents

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/


  #4   Report Post  
Posted to microsoft.public.excel.programming
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/




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Saving to users My Documents

Thanks to all!!

Rob Edwards


07092 108121

*** Sent via Developersdex
http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
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
Saving Word and Excel documents Chuck Excel Discussion (Misc queries) 1 August 17th 09 09:47 AM
Saving Excel documents during trial period iamdebt Excel Discussion (Misc queries) 2 May 13th 08 02:00 PM
saving documents with macros shrek Excel Worksheet Functions 1 November 10th 05 10:13 PM
Users suddenly able to modify the same documents at the same time. TxVics Excel Discussion (Misc queries) 0 May 18th 05 09:43 PM
Saving Documents from templates to specific places Linds[_2_] Excel Programming 1 October 23rd 03 04:25 PM


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