+ Reply to Thread
Results 1 to 7 of 7

Referencing Shared Drive in VBA

  1. #1
    Registered User
    Join Date
    05-07-2017
    Location
    Sydney, Australia
    MS-Off Ver
    Office 365
    Posts
    4

    Referencing Shared Drive in VBA

    I am trying to write a macro which opens a file in a specific location on a shared drive, however different computers on the network have mapped this drive to different letters, e.g. G:\ H:\ etc. As the file path will vary depending on this letter, the path I manually include in the code will not work unless the user has the same mapping as me.

    What I would like to know: is there a way to determine what letter this drive is mapped to in VBA, and therefore to assign this to a variable "DriveLetter" and change the file path to DriveLetter & ":\FilePath"?

    Any help would be very much appreciated.

  2. #2
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Referencing Shared Drive in VBA

    your macro could ask users to enter their drive letter through an INPUTBOX.
    Pierre Leclerc
    _______________________________________________________

    If you like the help you got,
    Click on the STAR "Add reputation" icon at the bottom.

  3. #3
    Registered User
    Join Date
    05-07-2017
    Location
    Sydney, Australia
    MS-Off Ver
    Office 365
    Posts
    4

    Re: Referencing Shared Drive in VBA

    I may end up having to do it this way, but i'm hoping for an automated way as some users are not tech savvy and may not know the answer to that.

  4. #4
    Forum Expert p24leclerc's Avatar
    Join Date
    07-05-2010
    Location
    Québec
    MS-Off Ver
    Excel 2021
    Posts
    2,081

    Re: Referencing Shared Drive in VBA

    is the file running your macro on the same drive as the one you want to open or not?
    If yes, you can use ActiveWorkbook.Path
    Last edited by p24leclerc; 05-07-2017 at 10:18 PM.

  5. #5
    Registered User
    Join Date
    05-07-2017
    Location
    Sydney, Australia
    MS-Off Ver
    Office 365
    Posts
    4

    Re: Referencing Shared Drive in VBA

    Unfortunately it will be distributed as an attachment via email.

  6. #6
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    9,653

    Re: Referencing Shared Drive in VBA

    This will look for a specific folder in all mapped network drives.
    Change the folder to suit.

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  7. #7
    Registered User
    Join Date
    05-07-2017
    Location
    Sydney, Australia
    MS-Off Ver
    Office 365
    Posts
    4

    Re: Referencing Shared Drive in VBA

    Thank you AlphaFrog, exactly what I needed!

+ 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. Check permissions to a shared drive
    By jjarra_mackem in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-07-2013, 07:13 AM
  2. Summary Sheet on Shared Drive
    By pauldaddyadams in forum Excel General
    Replies: 2
    Last Post: 11-28-2012, 09:44 AM
  3. Vlookup on shared drive
    By gmcconnell in forum Excel General
    Replies: 0
    Last Post: 07-19-2010, 09:38 AM
  4. VBA Shared Network Drive
    By Eighmey in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 02-12-2009, 04:48 PM
  5. Cannot delete macro on a shared drive?
    By robbert in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-20-2008, 05:49 PM
  6. track info on shared drive
    By pywhacket in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 03-26-2007, 09:19 AM
  7. [SOLVED] Excel on shared drive
    By Greg Snidow in forum Excel General
    Replies: 0
    Last Post: 08-25-2005, 12:05 PM
  8. [SOLVED] Problems Saving on a shared drive
    By Anthony in forum Excel General
    Replies: 0
    Last Post: 03-20-2005, 07:06 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