+ Reply to Thread
Results 1 to 5 of 5

VBA to validate UNC path

  1. #1
    Registered User
    Join Date
    07-09-2014
    Location
    Lisbon
    MS-Off Ver
    Microsoft Office 365 ProPlus Version 1708 (build 8431.2153)
    Posts
    62

    Question VBA to validate UNC path

    Hi everyone,

    I'm failing to get this working.
    So, I have a file save on a shared drive that anyone can map differently (M: Z: etc). The thing is, that file can only be used THERE, so if they copy and open it from any other place, the file is deleted.

    I've defined "Path" to be on cell B8 as this: \\IRLDUB02.eu.company.net\swg03\ABC\

    The piece of code is:
    Please Login or Register  to view this content.
    As I can understand the problem is that Application.ActiveWorkbook.Path is "reading" the mapped path. E.G. Z:\ABC instead of the UNC one.
    Does someone know how can I force it to use the UNC instead?

    Thank you.
    Last edited by no_Fate; 01-10-2018 at 01:16 PM.

  2. #2
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,938

    Re: VBA to validate UNC path

    Use

    Please Login or Register  to view this content.
    And here is some useful code:

    Please Login or Register  to view this content.
    Last edited by Bernie Deitrick; 01-10-2018 at 03:50 PM.
    Bernie Deitrick
    Excel MVP 2000-2010

  3. #3
    Registered User
    Join Date
    07-09-2014
    Location
    Lisbon
    MS-Off Ver
    Microsoft Office 365 ProPlus Version 1708 (build 8431.2153)
    Posts
    62

    Re: VBA to validate UNC path

    Hi @Bernie,

    Thank you, that does the job!

    Although, hopefully not sounding unthankful, that gives be the UNC path and the file name, like \\IRLDUB02.eu.company.net\swg03\ABC\file.xlsm
    Is it possible to only get the path?

    Thank you.

  4. #4
    Forum Expert
    Join Date
    02-11-2014
    Location
    New York
    MS-Off Ver
    Excel 365 (Windows)
    Posts
    5,938

    Re: VBA to validate UNC path

    Try

    Please Login or Register  to view this content.

  5. #5
    Forum Expert
    Join Date
    10-02-2014
    Location
    USA
    MS-Off Ver
    2016
    Posts
    1,222

    Re: VBA to validate UNC path

    I use the following UDF's to convert from UNC to Mapped and back.

    Please Login or Register  to view this content.
    Ways to get help: Post clear questions, explain your overall goal, supply as much background as possible, respond to questions asked of you by those trying to help and post sample(s) files.

    "I am here to help, not do it for people" -Me

+ 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. How to validate an input dat folder/directory path whether the path has any spaces
    By mahendra.asapu in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 07-21-2015, 02:39 AM
  2. Replies: 1
    Last Post: 11-26-2013, 08:46 PM
  3. Variable .Attachment.Add path using Function to pull path from word table
    By aavelyn in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-27-2013, 10:07 PM
  4. Macro with condition of Period, before run, macro should validate the date and Path of fil
    By caapoorvajain in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-17-2012, 04:11 AM
  5. How to set GetOpenfile dialog start path to current open files path.
    By Michael Wise in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-03-2010, 02:24 PM
  6. Validate two fields when one field you need a formula to validate
    By cmwilbur in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-29-2010, 11:32 AM
  7. Replies: 7
    Last Post: 10-09-2009, 10:10 AM

Tags for this Thread

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