how to read the path (1 Viewer)

hfsitumo2001

Member
Local time
Today, 05:05
Joined
Jan 17, 2021
Messages
365
Hello, when I browse our C using File Explorer, I see the server directory is like this "Shared (\\brilliant.sampl.abc.pqrs.org.org) (O:)
Can I just right the path in my backup VBA like this? Source = "\(\\brilliant.sampl.abc.pqrs.org.org) (O:)\xxxdatabase_be.accdb"
Thanks for any ideas
 

Ranman256

Well-known member
Local time
Today, 08:05
Joined
Apr 9, 2015
Messages
4,337
never use drive letters. Other users may not have it mapped.
Always use UNC paths :
vSource = "\\server\folder\file.txt"
 

Isaac

Lifelong Learner
Local time
Today, 05:05
Joined
Mar 14, 2017
Messages
8,777
Also, your original question looks like you are asking whether this literal string would ever be a valid path:

Code:
\\brilliant.sampl.abc.pqrs.org.org (O):\filename

The answer is ... No, it wouldn't. The (O) is telling you that that network folder is mapped as O, and therefore files are referred to by path as
O:\folder\folder\filename
OR, they are referred to as UNC path and filename: \\brilliant.sampl.abc.pqrs.org.org\filename

As Ranman said, it's a good idea to use UNC paths whenever you can, rather than *hoping* that the drive mapping will be existent, active and working at the time your code runs.

Occasionally, (and just today actually), I find it helpful to write code that maps a LONG unc path to a drive letter on-the-fly (and then kills it at the end of the code), because a lot of functions like Name() and filesystemobject's FileCopy tend to return troubles, like "path not found", with ultra-long paths. But that's a different story. Never hurts to know, though.
 

hfsitumo2001

Member
Local time
Today, 05:05
Joined
Jan 17, 2021
Messages
365
Also, your original question looks like you are asking whether this literal string would ever be a valid path:

Code:
\\brilliant.sampl.abc.pqrs.org.org (O):\filename

The answer is ... No, it wouldn't. The (O) is telling you that that network folder is mapped as O, and therefore files are referred to by path as
O:\folder\folder\filename
OR, they are referred to as UNC path and filename: \\brilliant.sampl.abc.pqrs.org.org\filename

As Ranman said, it's a good idea to use UNC paths whenever you can, rather than *hoping* that the drive mapping will be existent, active and working at the time your code runs.

Occasionally, (and just today actually), I find it helpful to write code that maps a LONG unc path to a drive letter on-the-fly (and then kills it at the end of the code), because a lot of functions like Name() and filesystemobject's FileCopy tend to return troubles, like "path not found", with ultra-long paths. But that's a different story. Never hurts to know, though.
Thank you Isaac
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 07:05
Joined
Feb 28, 2001
Messages
27,167
As an amplification, in our shop we had so many users with so many projects that already had drive-letter mappings that I had no choice but to use UNC mapping There was no drive letter I could use that worked for all 40 - 50 of my users.
 

Users who are viewing this thread

Top Bottom