Closed Thread
Results 1 to 7 of 7

Find the drive letter of a mapped network drive

  1. #1
    Registered User
    Join Date
    03-29-2017
    Location
    Florida
    MS-Off Ver
    2010
    Posts
    60

    Find the drive letter of a mapped network drive

    Does anyone have a piece of code that can help me find the letter of a mapped drive? I know the name of the drive, but the drive can be mapped to a different letter on each persons laptop who might run my macro. So I need a macro that looks for a drive letter associated with the name "\\secrets\"...

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,895

    Re: Find the drive letter of a mapped network drive

    Starting point: https://superuser.com/questions/3846...o-in-windows-7

    https://social.msdn.microsoft.com/Fo...r?forum=isvvba
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    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: Find the drive letter of a mapped network drive

    Hello BillyJo,

    The code below contains 2 macros. One to get the server path (UNC) from a mapped drive letter and the second to search all the drives in use on the computer and find a partial or complete match to the server name.

    Add a new VBA module to your workbook and paste this code into it.

    You would call the macro like this in your code...

    Macro Calling Example
    Please Login or Register  to view this content.
    Module Code
    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!)

  4. #4
    Registered User
    Join Date
    03-29-2017
    Location
    Florida
    MS-Off Ver
    2010
    Posts
    60

    Re: Find the drive letter of a mapped network drive

    Leith, you are a master. Much gratitude for taking the time for this!

  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: Find the drive letter of a mapped network drive

    Hello BillyJo,

    Mastery is born of both necessity and hard work. You're welcome.

  6. #6
    Registered User
    Join Date
    02-11-2019
    Location
    US
    MS-Off Ver
    MS Office 2013
    Posts
    1

    Re: Find the drive letter of a mapped network drive

    Dear Leith, thank you for the codes.

    Can you perhaps point out which areas of the codes must be updated to be compatible with MS Excel 2016, 64-bit? The codes worked beautifully in my old setting (Excel 2013, 32-bit), but it is now returning a null value for the network drives. Specifically, it appears that the following values are now Zero.

    Please Login or Register  to view this content.
    Please Login or Register  to view this content.
    P.s. I did replace "Private Declare Function" with "Private Declare PtrSafe Function" for the 64-bit.

  7. #7
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2405 Win 11 Home 64 Bit
    Posts
    23,895

    Re: Find the drive letter of a mapped network drive

    @agent_maxineAdministrative Note:

    Welcome to the forum.

    We are happy to help, however whilst you feel your request is similar to this thread, experience has shown that things soon get confusing when answers refer to particular cells/ranges/sheets which are unique to your post and not relevant to the original. Please start a new thread - See Forum rule #4

    If you are not familiar with how to start a new thread see the FAQ: How to start a new thread

Closed Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] OpenProcess throws an error on UNC path, but not on mapped network drive
    By wherbjr35 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-21-2014, 09:24 AM
  2. Replies: 0
    Last Post: 04-14-2014, 02:12 AM
  3. [SOLVED] VBA to check and see if network drive is mapped
    By [email protected] in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 08-29-2013, 10:02 PM
  4. Drive Letter Property not returning mapped drive letter
    By Mike_bee in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-26-2013, 02:45 PM
  5. Save files to a Mapped Network Drive on server
    By wotsup in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 03-12-2012, 11:46 AM
  6. Replies: 0
    Last Post: 10-07-2010, 10:37 AM
  7. Replies: 1
    Last Post: 10-17-2005, 01:05 PM

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