Obtain the share name of a folder on a server

wigi

Well-known Member
Joined
Jul 10, 2006
Messages
7,964
Office Version
  1. 365
Platform
  1. Windows
  2. Mobile
  3. Web
Hello all,

Does anyone know a way in VBA to get the share name(s) of a certain folder?

Detailed explanations:

I have access to a folder (say, D:\MyFolder) on a remote server in the network.
That folder is shared in order to have access, I do not have access anywhere else.
But I would like to programmatically obtain the share name, starting from in this example D:\MyFolder on the remote server.
Folder name is given and server name is given, and access to the folder is guaranteed.

Does anyone have an idea please?

Thanks in advance !
 
So if I understand correctly, you're trying to get the UNC Path of a share that has been mapped on the computer that created the config file? I don't see how you would do this, the "D:\TM1Data\ForecastModel\" Could refer to any folder on any server that has "\TM1Data\ForecastModel\" somewhere in the directory structure. Mapped drives vary user to user, so you'd need to know which user mapped the share (at the very least) - most map drives are done as part of the log-in routine via a .vbs script so can/will change.

My code will test whether
"D:\TM1Data\ForecastModel\" = "\\aexbeapps\TM1Data\ForecastModel\" for the currently logged in user (where the code is being executed):

Code:
if lcase("
Code:
[COLOR=#333333]\\aexbeapps\[/COLOR][COLOR=#333333]TM1Data\ForecastModel\[/COLOR][COLOR=#333333]")  = lcase([/COLOR][COLOR=#333333]UNC_From_Mapped("[/COLOR][COLOR=#333333]D:\TM1Data\ForecastModel\")) then
    Msgbox "Match"
End if
[/COLOR]

 
Last edited:
Upvote 0

Excel Facts

When they said...
When they said you are going to "Excel at life", they meant you "will be doing Excel your whole life".
I suspect you'd need to reverse the logic and test all the shares on the specified server (I'm assuming you know its name) and then check if the local path of the share matched the path you have in your cfg file. (using code similar to this to get the shares)
 
Upvote 0
Hello Kyle

The ingredients (user input) are:

server name: aexbeapps
share name: ForecastModel

or it could also be for example: \\aexbeapps\d$\TM1Data\ForecastModel

That folder contains a .cfg file containing a folder location as well.
Normally it is the same location as what is chosen above, but it could be in a different form (a local path instead of share name and so on).
I need to test whether both locations refer to the same physical directory.
Both folders could be on different machines.

Thanks for your valuable inputs.
 
Upvote 0
Thanks Rory, I will check it out tonight.
 
Upvote 0
Good suggestion too Andrew, thanks.
I will test this as well when time permits (coming evenings normally).
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,849
Members
452,361
Latest member
d3ad3y3

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top