+ Reply to Thread
Results 1 to 8 of 8

Different path for each user

  1. #1
    Registered User
    Join Date
    09-18-2018
    Location
    USA
    MS-Off Ver
    2010
    Posts
    8

    Different path for each user

    Hi everyone,

    I have created a macro that generates folders, populates them with some files and modify the files depending on what the user fills the userform with. It is working perfectly for me but not for some users that have the share-drive named under a different location. For example my share drive has been linked to X and other users to Z and Y.

    How can I make the macro search for the below path if they have a different location ?

    Please Login or Register  to view this content.
    Thank you for taking the time to help me.

  2. #2
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: Different path for each user

    You need to refer to the full path of X rather than using "X"

    ie

    if X is mapped to "C:\Documents\Data" then you would set the source path = C:\Documents\Data\Stock Divs......
    If someone has helped you then please add to their Reputation

  3. #3
    Registered User
    Join Date
    09-18-2018
    Location
    USA
    MS-Off Ver
    2010
    Posts
    8

    Re: Different path for each user

    My team and I have access to a shared Network Drive. I have it mapped as X: but they have as Z: or Y:. What is inside is the same for all of us.

  4. #4
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Different path for each user

    You need to use the full "UNC" path, not the mapped path

  5. #5
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Different path for each user

    Hello ImadEdd,

    This macro will return the UNC for a mapped drive. You can use this to return the UNC for the drive on your computer. You can then create a loop in your macro to test if any mapped drives on the user's computer match. Both macros can be copied to the same module.

    Macro to return UNC Path of a Mapped Drive
    Please Login or Register  to view this content.
    Loop to check User's Computer for Same Path
    Please Login or Register  to view this content.
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  6. #6
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: Different path for each user

    Now I'm a lover of VBA and creating functions to cover any eventuality however I cannot see the reason for the above in this instance?

    If you are linking to a file on a shared resource then simply refer to the full UNC and anybody who has access to that drive can use it, the above code is all very clever and don't get me wrong may well have some very useful application but in this instance its a sledgehammer and nut scenario and doesn't cover for those users (I'd stick my finger in the air and say at least 80% of users in my organisation) who don't map the drives at all and simply use shortcuts/ favourites or good old navigation to get to directories when they need them.

    replace "X:" with "\\Server1\CAF1\Directory5\etc\etc" and the jobs done.

  7. #7
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,238

    Re: Different path for each user

    I must admit, I agree with you, this feels a tad overengineered. I can see the use in the function that returns the UNC from a mapped drive, but I'm struggling to see the value of this unless whatever you are feeding the file path to only accepts mapped drives and not UNC, though you'd then have to make the drive if it didn't exist or was mapped to another level.

    Of course, I too may be missing the obvious

  8. #8
    Registered User
    Join Date
    09-18-2018
    Location
    USA
    MS-Off Ver
    2010
    Posts
    8

    Re: Different path for each user

    Thank you all for your answers.

    I have tried to replace "X" with the server's name but it gave me a bad file name or number error. I did not insert any character that is not supported.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Explorer to pop out for user to select path
    By jp16 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-13-2018, 01:31 AM
  2. [SOLVED] Saving pdf in the same path selected by user
    By ell_ in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-01-2018, 09:30 PM
  3. [SOLVED] Get directory path from user
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-27-2015, 09:02 PM
  4. Better way to get directory path info from user
    By welchs101 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 01-15-2014, 03:49 PM
  5. [SOLVED] Save As Dialog Box - Default Path and File Name, User Selects Sub Folder from Default Path
    By christenprochaska in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-12-2012, 05:17 PM
  6. User input for current path?
    By gshock in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-31-2008, 11:05 AM
  7. How to path to user's desktop
    By 1scant in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-16-2006, 10:52 AM

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