Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Saving Word and Excel documents | Excel Discussion (Misc queries) | |||
Saving Excel documents during trial period | Excel Discussion (Misc queries) | |||
saving documents with macros | Excel Worksheet Functions | |||
Users suddenly able to modify the same documents at the same time. | Excel Discussion (Misc queries) | |||
Saving Documents from templates to specific places | Excel Programming |