Results 1 to 4 of 4
  1. #1
    New Lounger
    Join Date
    Jul 2004
    Location
    Greenville, North Carolina, USA
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Specifying a User Name in Path to Import Data from (Excel 2003)

    I have a spreadsheet that multiple users will use. I want each user to be able to store and access data in a specific folder within their own user profile. I am trying to figure out how to put in a macro to open file x.csv located in cocuments and SettingsUser NameMy Documents. I do not want each to use to have to enter their user name. Does anyone know how to do this in a macro?

    Thanks for your help

  2. #2
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Specifying a User Name in Path to Import Data from (Excel 2003)

    Something like:
    <code>strPath = "cocuments and Settings" & environ("username") & "My Documents"</code>
    HTH
    Regards,
    Rory

    Microsoft MVP - Excel

  3. #3
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Specifying a User Name in Path to Import Data from (Excel 2003)

    You can also use:
    <code>strPath = createobject("WScript.Shell").specialfolders("MyDo cuments")</code>

    HTH.
    Regards,
    Rory

    Microsoft MVP - Excel

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Specifying a User Name in Path to Import Data from (Excel 2003)

    The path to the user's My Documents folder is

    CreateObject("WScript.Shell").SpecialFolders("MyDo cuments")

    Note that there is no space in "MyDocuments".

Posting Permissions

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