+ Reply to Thread
Results 1 to 5 of 5

Saving to users My Documents

Hybrid View

  1. #1
    Rob Edwards
    Guest

    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
    rob_edwards@bigfoot.com
    07092 108121

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

  2. #2
    galimi
    Guest

    RE: 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
    > rob_edwards@bigfoot.com
    > 07092 108121
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
    >


  3. #3
    Rob Bruce
    Guest

    Re: 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. #4
    Tom Ogilvy
    Guest

    Re: 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
    news:OJmdjjcGFHA.2976@TK2MSFTNGP09.phx.gbl...
    > 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. #5
    Rob Edwards
    Guest

    Re: Saving to users My Documents

    Thanks to all!!

    Rob Edwards
    rob_edwards@amat.com
    rob_edwards@bigfoot.com
    07092 108121

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

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1